DO WHILE loop

write pseudocode for the driven program that requests the user to select several shapes. The shapes are CIRCLE, RECTANGLE and TRIANGLE. Then, you will have to request the appropriate inputs and calculate the area of te selected shape. The area for

1.CIRCLE=3.141593*radius^2
2.RECTANGLE=length*width
3.TRIANGLE=(height*width)/2
4.QUIT

Then, produce the c++ program code. you will have to use DO...WHILE loop to repeat the program.

#include <iostream>
using namespace std;

int main()
{

char selection;

cout<<"Welcome to Vikramathitan calculator.\n\n";
cout<<"1.CIRCLE\n";
cout<<"2.RECTANGLE\n";
cout<<"3.TRIANGLE\n";
cout<<"4.EXIT\n";

selection:
cout<<"\nChose your option: ";
cin>>selection;
cout<<endl;

switch (selection)
{
int radius, circle, length, width, rectangle, height;
case '1':
cout<<"Please enter the radius of circle: ";
cin>>radius;
circle=3.141593*radius*radius;
cout<<"The area of circle is: "<<circle<<endl;
break;

case '2':
cout<<"Please enter the length of the rectangle: ";
cin>>length;
cout<<"Please enter the width of the rectangle: ";
cin>>width;
rectangle=length*width;
cout<<"The area of rectangle is: "<<rectangle<<endl;
break;

case '3':
cout<<"Please enter the height of the rectangle: ";
cin>>height;
cout<<"Please enter the width of the rectangle: ";
cin>>width;
rectangle=(height*width)/2;
cout<<"The area of triangle is: "<<rectangle<<endl;
break;

case '4':
cout<<"\nThank you for using our application.\n";
break;

default:
cout <<"Invalid selection! Please select again.\n";
cout<<endl;
goto selection;
}
return 0;
}

Can anybody help me with the do while loop to repeat the program
Hi,

How many times do you want to repeat the program or better said until when?

do while example:

do{
statement1;
statement2;
statement3;
etc...

}while(conditon);


Your statements are the case1 2 3.What is your condition?
Topic archived. No new replies allowed.