#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<math.h>
int main()
{
clrscr();
char ch,ch1;
float l,b,peri,area,diag;
cout<<"\nRectangle menu";
cout<<"\n 1.area";
cout<<"\n 2.perimeter";
cout<<"\n 3.diagonal";
cout<<"\n 4.exit"<<"\n";
cout<<"enter your choice:";
do
{
cin>>ch;
if(ch=='1'|| ch=='2'||ch=='3')
{ cout<<"enter length & breadth:";
cin>>l>>b;
}
switch(ch)
{ case '1': area = l*b;
cout<<"area="<<area;
break ;
case '2': peri = 2*(l+b);
cout<<"perimeter="<<peri;
break ;
case '3': diag =((l*l)+(b*b));
cout<<"diagnol="<<diag;
break ;
case '4': cout<<"breaking";
exit(0);
default : cout<<"wrog choice!!!!";
cout<<"enter a valid one";
break;
} // end of switch.
cout<<"\n want to enter more(y/n)?";
cin>>ch1;
if(ch1=='y'|| ch1=='y')
cout<<"again enter your choice(1-4):";
} while(ch1=='y'||ch1=='y'); //end of do-while loop
return (0);
}
#include<conio.h>
#include<process.h>
#include<math.h>
int main()
{
clrscr();
char ch,ch1;
float l,b,peri,area,diag;
cout<<"\nRectangle menu";
cout<<"\n 1.area";
cout<<"\n 2.perimeter";
cout<<"\n 3.diagonal";
cout<<"\n 4.exit"<<"\n";
cout<<"enter your choice:";
do
{
cin>>ch;
if(ch=='1'|| ch=='2'||ch=='3')
{ cout<<"enter length & breadth:";
cin>>l>>b;
}
switch(ch)
{ case '1': area = l*b;
cout<<"area="<<area;
break ;
case '2': peri = 2*(l+b);
cout<<"perimeter="<<peri;
break ;
case '3': diag =((l*l)+(b*b));
cout<<"diagnol="<<diag;
break ;
case '4': cout<<"breaking";
exit(0);
default : cout<<"wrog choice!!!!";
cout<<"enter a valid one";
break;
} // end of switch.
cout<<"\n want to enter more(y/n)?";
cin>>ch1;
if(ch1=='y'|| ch1=='y')
cout<<"again enter your choice(1-4):";
} while(ch1=='y'||ch1=='y'); //end of do-while loop
return (0);
}
No comments:
Post a Comment