What is wrong here?

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