You are on page 1of 4

#include <iostream>

#define PI 3.14159
using namespace std;
int main()
{
int num;
double rad,area,length,width,height;
cout<<"Geometry Calculator \n";
cout<<"1.Calculate Area of a Circle. \n";
cout<<"2.Calculate Area of Rectangle. \n";
cout<<"3.Calculate Area of Triangle. \n";
cout<<"4.Quit. \n";
cout<<"Enter your choice (1-4):\n ";
cin>>num;
switch(num){
case 1:
cout<<"Enter the radius of the circle.\n";
cin>>rad;
area= PI*rad*rad;
cout<<"The area of the circle is "<< area<<endl;
break;
case 2:
cout<<"Enter the length of the rectangle .\n";
cin>>length;
cout<<"Enter the width of the rectangle .\n";
cin>> width;
area=length*width;
cout<<" The area of the rectangle is "<< area<<endl;
break;
case 3:
cout<<"Enter the length of the base of the triangle .\n";
cin>>length;
cout<<"Enter the height of the triangle .\n";
cin>>height;
area=(length*height)/2;
cout<<" The area of the triangle is "<< area<<endl;
break;
case 4:
cout<<"The program has ended.\n";
break;
default:
cout<< " Invalid choice.\n";

}
return 0;
}

#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a positive integer.\n";
cin>>num;
if(num%2==0)
cout<<"The number is even.\n";
else
cout<<"The number is odd.\n";
}

return 0;

#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a positive integer.\n";
cin>>num;
switch(num%2)
{
case 1:
cout<<"The number is odd.\n";
break;

default:
cout<<"The number is even.\n";
break;
}
return 0;

#include <iostream>

using namespace std;


int main()
{
int num;
cout<<"Enter a positive integer.\n";
cin>>num;
(num%2==0)?cout<<"The number is even.":cout<<"The number is odd.";
return 0;

}
#include <iostream>
using namespace std;
int main()
{
char alp;
cout<<"Enter a character.\n";
cin>>alp;
{if((alp>='a'||'A')&&(alp<='z'||'Z'))
cout<<"The character is an alphabet.\n";
else
cout<<"Other character.\n";
}

You might also like