Archived

This topic is now archived and is closed to further replies.

Penguinzchaseme

Can someone help me with my code

Recommended Posts

for this code: #include <iostream> using namespace std; int main() { int score[5], t, x; int low, avg; char let; cout<<"Enter 5 test grades: \n"; for(t=0; t<=4; t++) { cin>>score[t]; } for(x=0,t=0;t<5 && x<5;t++) { for(;;x++) { if(x==5) low=score[t] break; else if(score[t]>score[x]) break; } } avg=(score[0]+score[1]+score[2]+score[3]+score[4]-score[t])/4; if(avg>90) let= ''A''; else if(avg>79 && avg<90) let= ''B''; else if(avg>74 && avg<80) let= ''C''; else if(avg>69 && avg<75) let= ''D''; else let=''F''; cout<<"The lowest test grade is "<

Share this post


Link to post
Share on other sites
quote:
Original post by Penguinzchaseme
{
if(x==5) low=score[t]*here* break; <------
else




you''re missing there a ;

that should do it



To be considered a genius you just have to say what everybody knows in a way very few understand

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''m anonymous because the moderators have fettered my name, . Your code allocates space for 6 grades, ie score[5],ie score[5]={0,1,2,3,4,5}...it should be score[4]; gotta remember the 0 is part of the array index!

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
I''m anonymous because the moderators have fettered my name, . Your code allocates space for 6 grades, ie score[5],ie score[5]={0,1,2,3,4,5}...it should be score[4]; gotta remember the 0 is part of the array index!


You got it wrong; score[5] allocates space for 5 variables from 0..4.


"George W. Bush Geography Simplification Initiative"

More info on George W. Bush
My Homepage (C++ SDL OpenGL Game Programming)

Share this post


Link to post
Share on other sites