please correct my source code

my answers are wrong. dont know what is wrong with the code though there are no build errors.



#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
//declarations
int operation;
double CirRadius, CirArea, Base, Height, TriArea;
const double PI = 3.14159;

// menu
cin >> operation;
while (operation !=4)
{
if (operation == 1)
{
cin >> CirRadius;
CirArea = PI * CirRadius * CirRadius;
cout<<"The area of a circle with radius "<<CirRadius<<" is " <<setprecision(4)<<CirArea<<'\n\n';
cin >> operation;
}
else if (operation == 2 || operation == 3)
{
cin >> Base;
cin >> Height;
TriArea = 0.5 * Base * Height;
cout<<"The area of a triangle with base "<<Base<<" and height "<<Height<<" is "<<TriArea<<'\n\n';
cin >> operation;
}
else if (operation == 5 || operation == 7)
{
cout<<"Error: "<<operation<<" is not a valid operation.\n\n";

}

}

return 0;
}
Put "" around your \n\n in place of single quotes. There is nothing wrong with your calculations but with your output.
So it should be
... <<TriArea<<"\n\n"
change \n to endl;

you dont have to post your problem in each forum..
Topic archived. No new replies allowed.