Hello everyone! Please help me, what's wrong with my code?
I'm trying an if only statement with multiple conditions because that's what our prof instructed. I just need one output on that but when I run it all of the circumference, area, diameter, exit is included in the output. Please help me!
#include <iostream>
usingnamespace std;
int main()
{
float Radius;
cout<<"Enter Radius: ";
cin>>Radius;
//Menu
char choice;
cout<<"\t\t\t\t"<<"MENU"<<endl<<endl;
cout<<"\t\t"<<"[C]"<<"\t"<<"Circumference of a Circle"<<endl;
cout<<"\t\t"<<"[A]"<<"\t"<<"Area of a Circle"<<endl;
cout<<"\t\t"<<"[D]"<<"\t"<<"Diameter of a Circle"<<endl;
cout<<"\t\t"<<"[E]"<<"\t"<<"Exit"<<endl;
cout<<"\t\t"<<"Enter your choice: ";
cin>>choice;
//If Statement
char C, c, A, a, D, d, E, e;
float pi, Circumference, Area, Diameter;
pi= 3.142;
if(choice== 'C' || "c"){
Circumference = 2 * pi * Radius;
cout<<endl;
cout<<"\t\t"<<"The Circumference of a Circle is "<<Circumference;
}
if(choice== 'A' || 'a'){
Area = pi * (Radius*Radius);
cout<<endl;
cout<<"\t\t"<<"The Area of a Circle is "<<Area;
}
if(choice== 'D' || 'd'){
Diameter = 2 * Radius;
cout<<endl;
cout<<"\t\t"<<"The Diameter of a Circle is "<<Diameter;
}
if(choice== 'E' || 'e'){
cout<<endl;
cout<<"\t\t"<<"Exiting...";
return 0;
}
return 0;
}
Thank you so much! It works. I'm just new also to this forum so I didn't know how to use code tags. Can you help me with that also?
Edit: I just discovered it haha
Thank you again @lastchance and @seeplus
Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you.
You can use the preview button at the bottom to see how it looks.