-
c program
I have this program that I wrote a few weeks ago:
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
float grade;
printf("\nEnter Grade:\n");
scanf("%f", &grade);
if( grade >= 90)
printf("Your grade is:A");
else if ( grade >= 80)
printf("Your grade: B");
else if ( grade >= 70)
printf("Your grade: C");
else if ( grade >= 60)
printf("Your grade: D");
else if ( grade <= 59)
printf("Your grade: F");
return 0;
_getch();
}
Now i have to repeat this for 6 students. How do I know which loop to use?
-
Are you sitting in class during a test asking us these questions?
For, While and Do While Loops in C - Cprogramming.com
-
Unless the grade variable can be a floating point number, always use an integer for number variable data types.
You can use a while loop, but if you know the number of times you need to loop (6 in this case), then a for loop is easiest and clearest.
-
http://cboard.cprogramming.com/c-pro...t-process.html
Study carefully what happens at step 5.
When you have a function to process one student, write a loop to call it 6 times.