Monday, July 12, 2010

A program to enter choice and display the message

#include
#include
void main()
{
int a,b,c,choice;
clrscr();
cout<<"enter 1st number: ";
cin>>a;
cout<<"enter 2nd number: ";
cin>>b;
cout<<"enter the choice from 1,2,3,4: ";
cin>>choice;
switch(choice)
{
case 1:
c=a+b;
cout<<"the result is: "<
break;
case 2:
c=a-b;
cout<<"the result is: "<
break;
case 3:
c=a*b;
cout<<"the result is: "<
break;
case 4:
c+a/b;
cout<<"the result is: "<
default:
cout<<"invalid choice";
}
getch();
}

No comments:

Post a Comment