0

Hey i am a beginner in programming
I typed the following program on my own
But there are a lot of errors it it
Please help me find them

#include<IOSTREAM.h>
main()
{
int a,b,c,x;
cout<<"Enter three values - \nA,B,c.";
cout<<"A-";
cin>>a;
cout<<"B-";
cin>>b;
cout<<"c-";
cin>>c;
if (a>b) x=1 else x=2;
{switch(x)
case : 1 if (a>c)cout<<"A is the greatest" else cout<<"C is the greatest";
break;
case : 2 if (b>c)cout<<"B is the greatest" else cout<<"C is the greatest";
break;}
return 0;
}

Edited by WaltP: Added CODE Tags -- please use them

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by rohan121212
0

I think main should have a return type (since you are returning 0 ,it should be int).
Also case statements must be in a parenthesis block
{
if....
else....
break;
}

0

I was able to correct it on my own
Still thanks

Here is the solution

#include<IOSTREAM.h>
main()
{
int a,b,c,x;
cout<<"Enter three values - \nA,B,c.";
cout<<"A-";
cin>>a;
cout<<"B-";
cin>>b;
cout<<"c-";
cin>>c;
if (a>b)
x=1;
else x=2;
switch(x){
case 1: if (a>c)
cout<<"A is the greatest";
else cout<<"C is the greatest";
break;
case 2: if (b>c)
cout<<"B is the greatest";
 else cout<<"C is the greatest";
break;}
return 0;
}

Edited by WaltP: Added CODE Tags -- please use them

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.