cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
What is wrong here?
What is wrong here?
Feb 19, 2010 at 1:36am UTC
ksport99
(20)
There is an error in this piece of my code...can anyone see what it is?
if (avg1 > avg2 && avg1 > avg3) {
cout << name1 << "has the highest batting average with" << avg1 << endl;
if (avg2 > avg1 && avg2 > avg3)
cout << name2 << "has the highest batting average with" << avg2 << endl;
if (avg3 > avg1 && avg3 > avg 2)
cout << name3 << "has the highest batting average with" << avg3 << endl;
}
Thanks
Feb 19, 2010 at 1:37am UTC
tummychow
(1210)
Why did you wrap the whole thing with curly braces? Shouldn't there be one pair per if statement?
http://www.cplusplus.com/doc/tutorial/control/
In addition, all code belongs in code tags.
Feb 19, 2010 at 1:41am UTC
yoked88
(140)
If you code it like that, I would suggest testing three additional loops:
if
(avg1 > avg3 && avg1 > avg2)
and similar for the others.
Topic archived. No new replies allowed.