N
N
nkorobkov2015-12-17 17:30:14
Programming
nkorobkov, 2015-12-17 17:30:14

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;
}

Here is the flowchart (don't swear, I'm just learning):
4d8ad69f88c04500b346b8fad63f1733.jpge2ea7161dea64b54a19159dcbab3fc8a.jpgIs the flowchart correct and what needs to be corrected to make it perfect?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg Tsilyurik, 2015-12-17
@Olej

Is the flowchart correct, and what needs to be corrected to make it perfect?

A flowchart cannot be perfect, if only because many authoritative authors have long ago come to the conclusion that the very practice of drawing up flowcharts is vicious and evil.

I
ivkol, 2015-12-17
@ivkol

Not ideal, because the block diagram must be drawn up first, and then the code on it. You have the opposite.

A
abcd0x00, 2015-12-18
@abcd0x00

Do you even know that a flowchart should be drawn up before the code, and not vice versa?
Because it looks like a confusing flowchart made up of confusing code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question