I need help writing a program that asks the user to enter the number of grades that he/she wants to enter, reads this many number of integer grades (assume each grade is in the range 0..100), and the prints the average of all the grades with 1 decimal point.
Help writing this program
Collapse
X
-
Where is the code that you have tried to write yourself?Originally posted by bjeffersI need help writing a program that asks the user to enter the number of grades that he/she wants to enter, reads this many number of integer grades (assume each grade is in the range 0..100), and the prints the average of all the grades with 1 decimal point. -
This is what I have so far.Originally posted by r035198xWhere is the code that you have tried to write yourself?
#include<stdio. h>
main()
{
int integer;
int integer2;
int integer3;
int integer4;
printf( "Enter number of grades:\n" );
scanf("%d" , &integer2);
printf( "Enter grade 1:\n" );
scanf("%d" , &integer2);
printf( "Enter grade 2:\n" );
scanf("%d" , &integer3);
printf( "Enter grade3:\n" );
scanf("%d" , &integer4);
if ( integer2 + integer3 + integer4 /3 );
printf( "The average of all 3 grades is %d\n" );
}
I just can't seem to grasp this stuff.Thanks...Comment
-
Understanding what an array is would be quite beneficial. Why don't you look at this thread, which talks about arrays. This other person has a similar problem as you do.Comment
Comment