Switch Case
#include<iostream.h>
#include<conio.h>
void main()
{
int choice,l,b,r;
float result;
clrscr();
cout<<"1.area of right angle"<<endl;
cout<<"2.area of rectangle"<<endl;
cout<<"3.area of circle"<<endl;
cout<<"4.araa of square"<<endl;
cout<<"enter your choice number"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"enter two value right angle";
cin>>l>>b;
result=0.5*l*b;
cout<<"result is"<<result;
break;
case 2:
cout<<"enter two value of rectangle";
cin>>l>>b;
result=l*b;
cout<<"result is"<<result;
break;
case 3:
cout<<"enter value of circle";
cin>>r;
result=3.14*(r*r);
cout<<"result is"<<result;
break;
case 4:
cout<<"enter value of square";
cin>>r;
result=r*r;
cout<<"result is"<<result;
break;
default:
cout<<"enter wrong choice";
}
getch();
}
#include<conio.h>
void main()
{
int choice,l,b,r;
float result;
clrscr();
cout<<"1.area of right angle"<<endl;
cout<<"2.area of rectangle"<<endl;
cout<<"3.area of circle"<<endl;
cout<<"4.araa of square"<<endl;
cout<<"enter your choice number"<<endl;
cin>>choice;
switch(choice)
{
case 1:
cout<<"enter two value right angle";
cin>>l>>b;
result=0.5*l*b;
cout<<"result is"<<result;
break;
case 2:
cout<<"enter two value of rectangle";
cin>>l>>b;
result=l*b;
cout<<"result is"<<result;
break;
case 3:
cout<<"enter value of circle";
cin>>r;
result=3.14*(r*r);
cout<<"result is"<<result;
break;
case 4:
cout<<"enter value of square";
cin>>r;
result=r*r;
cout<<"result is"<<result;
break;
default:
cout<<"enter wrong choice";
}
getch();
}
Post a Comment