Hi,
I have the following code which works as expected, however, if i remove the variable declartion "int i = 0" and declare it inside the for loop by adding the keyword int, i am getting a parsed error before int and that i is undeclared. Could someone tell me what I am doing wrong please?
Thanks
Code:
#include <stdio.h>
int main()
{
int marks[10];
int count = 10;
int i = 0;
long sum = 0L;
float average = 0.0f;
printf("Enter Student's Marks\n");
for (i = 0; i < count; ++i)
{
printf("%2d>\t", i+1);
scanf("%d", &marks[i]);
sum += marks[i];
}
printf("The total sum is %ld", sum);
average = (float) sum/count;
printf("The average is %.2f", average);
printf("\nThese are the grades entered\n");
for (int i = 0; i < count; i++)
printf("\nStudent %d has a grade of %d\n", i+1, marks[i]);
system("PAUSE");
return 0;
}