First, make sure your code is consistently indented - it should look more like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
int main()
{
int grade[4],average=0,cnt=0;
for(cnt=0;cnt<=4;cnt++)
{
scanf("%d ", &grade[cnt]);
}
printf("\n\n");
for(cnt=0;cnt<=4;cnt++)
{
printf("%d\n", grade[cnt]);
}
return 0;
}
This declares an array with 4 elements, not 5.
Code:
for(cnt=0;cnt<=4;cnt++)
The more common idiom is to use less-than here:
Code:
for(cnt=0;cnt<5;cnt++)
This allows you to used a named constant in lieu of a magic number:
Code:
#define NUM_GRADES 5
// ...
int grade[NUM_GRADES];
// ...
for(cnt=0; cnt<NUM_GRADES; cnt++)
// ...
Code:
scanf("%d ", &grade[cnt]);
That space after %d is causing the unexpected behavior you are seeing - try deleting it.
Also, "conio.h" is a non-portable and non-standard header, so you shouldn't include it - especially since you're not using any functions from it.