C++ : a menu base program for a. Area of rectangle b. Perimeter of rectangle c. exit


#include<iostream>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>

using namespace std;

void menu();
void clear();


int main()
{
char ch;
float l,b;
do{
clear();
menu();
ch=getch();
switch(ch)
{
case 'a':
cout<<"Enter Length & Breadth sequently : ";
cin>>l>>b;
cout<<"\n\nParameter = "<<2*(l+b);
getch();
clear();
menu();
case 'b':
cout<<"Enter Length & Breadth sequently : ";
cin>>l>>b;
cout<<"\n\nArea = "<<l*b;
getch();
clear();
menu();
case 'c':
break;
}

}while(ch!='c');
getch();
return(0);
}


void clear()
{
system("cls");
}

void menu()
{
    cout<<"================================================\n";
cout<<"Press a for Area of rectangle.\n";
cout<<"Press b for Perimeter of rectangle.\n";
cout<<"Press c for Exit.\n";
}

No comments:

Post a Comment