if esle statements, program outputs the wrong counts C++

Hi, this is maybe my fourth program ever for progamming ever, and something is wrong with the semicolons I think within the if esle statements but when I remove them, I get errors telling me that I need them there.
I am trying to convert the numerical grades to letter grades and count the number of each (A's, B's,...ect)

#include "stdafx.h"


int main()
{
int count60 = 0, count70 = 0, count80 = 0, count90 = 0, count100 = 0, i;


int n[10] = {99, 97, 91, 88, 85, 82, 77, 75, 63, 40};

for (i = 0; i <= 10; i++){





if (n[i] < 60)
{printf("%4d", n[i]);
printf(" \t F \n");
count60++;}

else if (n[i] < 70)
{printf("%4d", n[i]);
printf(" \t D \n");
count70++;}

else if (n[i] < 80)
{printf("%4d", n[i]);
printf(" \t C \n");
count80++;}

else if (n[i] < 90)
{printf("%4d", n[i]);
printf(" \t B \n");
count90++;}

else (n[i] <= 100);
{printf("%4d", n[i]);
printf(" \t A \n");
count100++;}
}

printf("\n\t A \t B \t C \t D \t F \n");
printf("\t%4d %4d %4d %4d %4d \n", count100, count90, count80, count70, count60);

return 0;
}
Looks like the error is in the else part of your if/then/else.
 
else (n[i] <= 100);


else takes no parameters. If you want it to have a parameter, change it to else if. Also take off the semicolon after it as well.
Your program is missing a #include<stdio.h> at the beginning and #include "stdafx.h" is not a standard library in C++ and I see it is not needed in your program.
Last edited on
Topic archived. No new replies allowed.