Answer the question
In order to leave comments, you need to log in
Is the flowchart of the program correct, and what needs to be changed to make it perfect?
I am creating a flowchart for lab work.
Here is the program:
#include <stdio.h>
#include <stdlib.h>
int main(){
float a, b, c, result, dx, x1, x2;
printf("Enter A\n");
scanf("%f", &a);
printf("Enter B\n");
scanf("%f", &b);
printf("Enter C\n");
scanf("%f", &c);
printf("Enter X1\n");//X1 начальный
scanf("%f", &x1);
printf("Enter X2\n");//X2 конечный
scanf("%f", &x2);
printf("Enter step - dx\n");
scanf("%f", &dx);
printf("\nA = %f\n", a);
printf("B = %f\n", b);
printf("C = %f\n", c);
printf("X1 = %f\n", x1);
printf("X2 = %f\n\n", x2);
printf("Step dx = %f\n\n", dx);
printf("X1:\t\tResult:\n\n");
while( x1 <= x2 ){
if(x1 < 0 && b != 0){
result = a*x1*x1+b;
printf("%f\t%f\n", x1, result);
}
else if(x1 > 0 && b == 0){
result = (x1 - a)/(x1 - b);
printf("%f\t%f\n", x1, result);
}
else{
if(c != 0){
result = x1/c;
printf("%f\t%f\n", x1, result);
}
else{
printf("%f\tSorry, but variable can be equal to 0\n", x1);
}
}
if( (x2-x1) < dx && (x2-x1) != 0 ){
x1+=(x2-x1);
}
else{
x1+=dx;
}
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
Is the flowchart correct, and what needs to be corrected to make it perfect?
Not ideal, because the block diagram must be drawn up first, and then the code on it. You have the opposite.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question