Wednesday, 19 October 2016

PROGRAMME FOR ADD,SUBS,MUL,DIV BY SWITCH STATEMENT

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,d,ch;
cout<<"enter the number";
cin>>a>>b;
cout<<"1.Addition of number\n";
cout<<"2.Substraction of number\n";
cout<<"3.Multiplication of number\n";
cout<<"4.Division of number\n";
cout<<"enter your choice for operation of numbers\n";
cin>>ch;
switch(ch)
{
case 1:
d=a+b;
cout<<"the sum of numbers will be\n"<<d;
break;
case 2:
d=a-b;
cout<<"the difference of numbers will be\n"<<d;
break;
case 3:
d=a*b;
cout<<"the product of numbers will be\n"<<d;
break;
case 4:
d=a/b;
cout<<"the division of numbers will be\n"<<d;
break;
default:
cout<<"the entered choice is invalid";
break;
}
getch();
}

No comments:

Post a Comment