I've just finished typing my code in C, but I don't know how to draw a flowchart. Can somebody help me create a flow chart of this C program please?
#include <stdio.h>
int main(void){
char answer; // user's inputted single character
int score = 0; // initialize score to 0
printf("-----------------------------------\n");
printf("\tMood Self Assessment\n");
printf("-----------------------------------\n");
printf("This Mood Self-Assessment program can help you determine
and understand how\nyou are feeling recently.");
printf("The user has to answer 3 questions honestly and\ntruthfully
in order to have an accurate outcome.");
printf("You may now begin the test!\n\n");
int flag = 0; // set a flag to 0
do{ // do-while loops if the user enters other letters instead
of a, b, c, d, and e.
printf("\n1. Do you feel bothered by feeling down or depressed
lately?\n\n");
printf("a. Strongly disagree\nb. Disagree\nc. No opinion\nd.
Agree\ne. Strongly Agree\n");
printf("\nYou answered: ");
scanf(" %c%*[^\n]", &answer); // scan a single character
switch (answer){
case 'a':
score = score + 5;
flag = 1; // set the flag to 1 if the user enters 'a'.
break;
case 'b':
score = score + 4;
flag = 1; // set the flag to 1 if the user enters 'b'.
break;
case 'c':
score = score + 3;
flag = 1; // set the flag to 1 if the user enters 'c'.
break;
case 'd':
score = score + 2;
flag = 1; // set the flag to 1 if the user enters 'd'.
break;
case 'e':
score = score + 1;
flag = 1; // set the flag to 1 if the user enters 'e'.
break;
default:
printf("\n----------------------------------------------");
printf("\nPlease enter a \"lower case\" letter from a to
e\n");
printf("----------------------------------------------\n");
}
} while(flag == 0); // if the flag is 0, loop once the do-while. If
it's 1, it continues on.
printf("Your answer: %c\n", answer);
flag = 0; // flag is reset to 0
do{
printf("\n2. Is social pressure affecting your daily
life?\n\n");
printf("a. Strongly disagree\nb. Disagree\nc. No opinion\nd.
Agree\ne. Strongly Agree\n");
printf("\nYou answered: ");
scanf(" %c%*[^\n]", &answer);
switch (answer){
case 'a':
score = score + 5;
flag = 1;
break;
case 'b':
score = score + 4;
flag = 1;
break;
case 'c':
score = score + 3;
flag = 1;
break;
case 'd':
score = score + 2;
flag = 1;
break;
case 'e':
score = score + 1;
flag = 1;
break;
default:
printf("\n----------------------------------------------");
printf("\nPlease enter a \"lower case\" letter from a to
e\n");
printf("----------------------------------------------\n");
}
} while(flag == 0);
printf("Your answer: %c\n", answer);
flag = 0;
do{
printf("\n3. Are you unable to sleep due to situations happening in
your daily life?\n\n");
printf("a. Strongly disagree\nb. Disagree\nc. No opinion\nd.
Agree\ne. Strongly Agree\n");
printf("\nYou answered: ");
scanf(" %c%*[^\n]", &answer);
switch (answer){
case 'a':
score = score + 5;
flag = 1;
break;
case 'b':
score = score + 4;
flag = 1;
break;
case 'c':
score = score + 3;
flag = 1;
break;
case 'd':
score = score + 2;
flag = 1;
break;
case 'e':
score = score + 1;
flag = 1;
break;
default:
printf("\n----------------------------------------------");
printf("\nPlease enter a \"lower case\" letter from a to
e\n");
printf("----------------------------------------------\n");
}
} while(flag == 0);
printf("Your answer: %c\n", answer);
printf("\n---------------------------");
printf("\nHow are you feeling lately?\n");
printf("---------------------------\n\n");
printf("Your score is %d/15\n", score);
if(score >= 12 && score <= 15) // interval of low
to below average depression level
{
printf("\nLevel of Depression: low to below average\n\n");
printf("Thanks for taking time to complete the questions! The
result shows that you are likely not depressed.\n");
printf("If there may be a bit of depression within you, don't worry
because it will eventually go away.\n");
printf("You may retake the quiz anytime again to check how might
you are feeling!! :)\n");
}
else if(score >= 8 && score <= 11) // interval of
below average to average depression level
{
printf("\nLevel of Depression: below average to
average\n\n");
printf("You are showing some kind of a depression. You are
experiencing symptoms that are seen in anxiety. The feeling
\n");
printf("of anxious from time to time is normal but if it is
affecting your life, you should take some action against
it.\n");
printf("You can seek moral support from your friends or your
family, and you will be fine as time passes by.\n");
}
else if(score >= 4 && score <= 7) // interval of
average to above average depression level
{
printf("\nLevel of Depression: average to above
average\n\n");
printf("You are experiencing the symptoms of Depression. This means
you are having the effect in your daily life both\n");
printf("physically and mentally. There will be some cases of
anxiety or panic attack occuring throughout the time,
which\n");
printf("it is important for you to overcome this harmful effect.
You can seek help from Depression Helpline on
0800-111-757.\n");
}
else if(score >= 0 && score <= 3) // interval of
average to high depression level
{
printf("\nLevel of Depression: above average to high\n\n");
printf("You have Crippling Depression. This is a serious case, and
you MUST consult a Mental Health Professional\n");
printf("You may feel suicidal, or the need to hurt yourself. Please
immediately reach out straight away for someone\n");
printf("who's trained for help. Call Depression Helpline on
0800-111-757.\n");
}
return 0;
}
iam giving hand written solution
Get Answers For Free
Most questions answered within 1 hours.