Jump to content
  • Advertisement

Archived

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

Penguinzchaseme

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.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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 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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!