if this is in c or java (few differences, same idea)
int x, sum;
while(i<3)
{
printf("Enter a grade: ");
scanf(%d, x);
sum+=x;
i++;
}
printf("Average: %d", sum/3);
replace %d with %lf and initialize variables as a double if you aren't using whole number grades or don't want a whole number rounded average. Also if the number of grades isn't always 3, add another variable to count that and use total++; to make a total grades counter.