You are on page 1of 4

SAMPLE #1

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

float num1,num2,sum,dif,pro,quo;
char choice;

main()
{
clrscr();
cout<<"M E N U"<<endl;
cout<<"[A] Addition "<<endl;
cout<<"[B] Subtraction "<<endl;
cout<<"[C] Multiplication"<<endl;
cout<<"[D] Division"<<endl<<endl;

cout<<"Enter choice: ";


cin>>choice;

if (choice=='a' || choice=='A')
{
cout<<endl<<"Enter first number: ";
cin>>num1;
cout<<"Enter second number: ";
cin>>num2;

sum=num1+num2;
cout<<"The sum of "<<num1<<" and "<<num2<<" is "<<sum;
}

else if (choice=='b' || choice=='B')


{
cout<<endl<<"Enter first number: ";
cin>>num1;
cout<<"Enter second number: ";
cin>>num2;

dif=num1-num2;
cout<<"The difference of "<<num1<<" and "<<num2<<" is "<<dif;
}

else if (choice=='c' || choice=='C')


{

cout<<endl<<"Enter first number: ";


cin>>num1;
cout<<"Enter second number: ";
cin>>num2;

pro=num1*num2;
cout<<"The product of "<<num1<<" and "<<num2<<" is "<<pro;
}
else if (choice=='d' || choice=='D')
{

cout<<endl<<"Enter first number: ";


cin>>num1;
cout<<"Enter second number: ";
cin>>num2;

quo=num1/num2;
cout<<"The quotient of "<<num1<<" and "<<num2<<" is "<<quo;
}

else
{
cout<<"INVALID SELECTION";
}

getch();
return 0;

SAMPLE #2

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

char option;

main()
{
clrscr();

cout<<"A. Dog "<<endl;


cout<<"B. Cat "<<endl;
cout<<"C. Mouse "<<endl<<endl;

cout<<"Enter option: ";


cin>>option;

if (option=='a' || option=='A')
{
cout<<"DOG";
}

else if (option=='b' || option=='B')


{
cout<<"CAT";
}
else if (option=='c' || option=='C')
{
cout<<"Mouse";
}

else
{
cout<<"INVALID SELECTION";
}

getch();
return 0;
}

SAMPLE #3

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

float side,area,length,width,base,height,radius;
char choice;

main()
{
clrscr();

cout<<"[A] Square"<<endl;
cout<<"[B] Rectangle"<<endl;
cout<<"[C] Triangle"<<endl;
cout<<"[D] Circle"<<endl<<endl;

cout<<"Enter choice: ";


cin>>choice;

if (choice=='a' || choice=='A')
{
cout<<"\n\nAREA OF A SQUARE"<<endl<<endl;
cout<<"Enter side: ";
cin>>side;
area=side*side;
cout<<"\n\nArea :"<<area;
}

else if (choice=='b' || choice=='B')


{
cout<<"\n\nAREA OF A RECTANGLE"<<endl<<endl;
cout<<"Enter length: ";
cin>>length;
cout<<"Enter width: ";
cin>>width;
area=length*width;
cout<<"\n\nArea :"<<area;
}

else if (choice=='c' || choice=='C')


{
cout<<"\n\nAREA OF A TRIANGLE"<<endl<<endl;
cout<<"Enter base: ";
cin>>base;
cout<<"Enter height: ";
cin>>height;

area=0.5*base*height;
cout<<"\n\nArea :"<<area;
}

else if (choice=='d' || choice=='D')


{
cout<<"\n\nAREA OF A CIRCLE"<<endl<<endl;
cout<<"Enter radius: ";
cin>>radius;

area=3.14*(radius*radius);
cout<<"\n\nArea :"<<area;
}

else
{
cout<<"\n\nINVALID SELECTION";
}

getch();
return 0;
}

You might also like