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;
}

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;
}

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.