#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,ch;
clrscr();
printf(“\n1.add\n2.subtract\n3.multiply\n4.division\n5.remainder\n);
printf(“\nenter your choice\n”);
scanf(“%d”,&ch);
switch(ch)
{
case1:
printf(“\nenter values of a and b\n”);
scanf(“%d%d”,&a,&b);
c=a+b;
printf(“\nthe answer is %d”,c);
break;
case2:
printf(“\nenter values of a and b\n”);
scanf(“%d%d”,&a,&b);
c=a-b;
printf(“\nthe answer is %d”,c);
break;
case3:
printf(“\nenter values of a and b\n”);
scanf(“%d%d”,&a,&b);
c=a*b;
printf(“\nthe answer is %d”,c);
break;
case4:
printf(“\nenter values of a and b\n”);
scanf(“%d%d”,&a,&b);
c=a/b;
printf(“\nthe answer is %d”,c);
break;
case5:
printf(“\nenter values of a and b\n”);
scanf(“%d%d”,&a,&b);
c=a%b;
printf(“\nthe answer is %d”,c);
break;
default:
printf(“\nenter the correct choice”);
break;
}
getch();
}
Output:
1.add
2.subtract
3.multiply
4.division
5.remainder
enter your choice
2
enter the values of a and b
7
4
the answer is 3
No comments:
Post a Comment