-
June 8th, 2010, 10:17 PM
#1
Syntax Error that I can't find
I'm writing a simple program for testing yourself on various fraction math problems. I keep getting a syntax error that I have a misplaced, or missing '}' but I've counted the brackets in my entire program from start to finish at least four times and I can't see it. Any help?
I'm using a struct to hold the fractions, here is the code.
struct frac
{
int nume;
int denom;
};
And here is the code for the function that it says is missing the bracket.
void addTest()
{
cout << "Would you like to include improper fractions in your test <y/n>?\n";
char c;
cin >> c;
if(c=='y' || c=='Y')
{
do{
frac f1 = genFrac(true);
frac f2 = genFrac(true);
frac fSolved;
fSolved.nume=(f1.nume*f2.denom)+(f2.nume*f1.denom);
fSolved.denom=f1.denom*f2.denom;
reduceFrac(fSolved);
cout << "What is " << f1.nume << "/" << f1.denom << " plus " << f2.nume << "/" << f2.denom <<"?\n";
int nume, denom;
char temp;
cin >> nume >> temp >> denom;
if(nume == fSolved.nume && denom == fSolved.denom)
{
cout << "You got it right! Awesome \n";
}else
{
while(nume == fSolved.nume || denom == fSolved.denom)
{
cout << "Darn, that's not right!\n"
<< "If you want to try the same problem again enter <y>.\n";
if(c=='y' || c=='Y')
{
cout << "What is " << f1.nume << "/" << f1.denom << " plus " << f2.nume << "/" << f2.denom <<"?\n";
cin >> nume >> temp >> denom;
}else
{
break;
}
}
}
}
}
}
I don't know if it's just my eyes or what, but any help would be appreciated.
-
June 8th, 2010, 11:49 PM
#2
Re: Syntax Error that I can't find
It has to do with your
do{ missing a closing while statement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|