Archived

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

Can someone help me with my code

This topic is 5725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 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 on other sites
Change the line where says...

if(x==5) low=score[t] break;

and there put...

if(x==5) {low=score[t]; break;}

I hope that this was the problem.

Share on other sites
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 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"

My Homepage (C++ SDL OpenGL Game Programming)

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 47
• Forum Statistics

• Total Topics
632636
• Total Posts
3007574
• Who's Online (See full list)

There are no registered users currently online

×