Dear asahi,
Here is how to solve exercise 4.
The QUESTION IS:
So..
To solve it..
1. You must understand what the programming will do?
2. Write down the flow of the programming or you might straight away draw the flow chart.
the example on the flow chart is as followed:
base on the flow chart.
write a coding.
Here is the example which implementing while loop.
#include <stdio.h>
main()
{
int a =1;
float total = 0;
int total_A = 0;
int total_B = 0;
int total_C = 0;
int total_D = 0;
int total_F = 0;
float marks;
while (a<19) // be aware that in the flow chart i just use 11 for 10 value, in the test data it give 18
values.
{
printf("\nInsert the %d's student's marks = ", a);
scanf("%f", &marks);
if (marks>100) {
printf("Invalid marks value(must be less than 100)");
} else if (marks>=90) {
//printf("Grade is: A");
total_A+=1;
} else if (marks>=70) {
//printf("Grade is: B");
total_B+=1;
} else if (marks>=50) {
//printf("Grade is: C");
total_C+=1;
} else if (marks>=35) {
//printf("Grade is: D");
total_D+=1;
} else if (marks>=0) {
//printf("Grade is: F");
total_F+=1;
} else {
printf("Invalid score");
}
a++;
}
printf("A's scorer = %d\n",total_A);
printf("B's scorer = %d\n",total_B);
printf("C's scorer= %d\n",total_C);
printf("D's scorer= %d\n",total_D);
printf("D's scorer= %d\n",total_F)
}
0 Responses to "exercise 4(unit 3) solution"
Post a Comment