Please find the mistakes

#include<iostream.h>
#include<conio.h>
class xyz
{
float l,b,a1,pi,r,a2;
public:
void switch();
};
void rectangle();
{
cout<<"\n enter the value of l=";
cin>>l;
cout<<"\n enter the value of b=";
cin>>b;
a1=l*b;
cout<<a1;
}
void circle();
{
pi=3.15;
cout<<"\n enter the value of r=";
cin>>r;
a2=pi*r*r;
cout<<a2;
}
void main()
{
int ch;
xyz k;
cout<<"press 1 for rectangle and press 2 for circle";
cin>>ch;
switch(ch);
{
case 1 :
k.rectangle();
break;
case 2:
k.circle();
break;
default:
cout<<"wrong choice";
}
getch();
}
Last edited on
a) please use code tags
b) dont use conio.h
c) dont use iostream.h
d) we need more information
I want to write a program with switch statements. It writes area of rectangle when we press 1 and area of circle when we press2 else prints wrong choice. plz write the corrected program.
Even if you ask politely (and you are definitely not), no one will write your entire program for you.
switch(ch);
Get rid of the semicolon here.
Why this:
 
void switch();

in your class declaration?
No need to prototype a switch statement because it's a statement. That's like putting a proto in for all your if blocks
Topic archived. No new replies allowed.