#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
char operator;
clrscr();
printf("Enter A,B values:");
scanf("%d %d",&a,&b);
printf("Choose one of the operator\n");
printf(" + for addition \n - for subtraction \n * for multiply \n / for division \n \% modulus\n");
fflush(stdin);
scanf("%c",&operator);
switch(operator)
{
case '+' : printf("sum %d + %d= %d",a,b,a+b);
break;
case '-' : printf("Subtraction %d - %d = %d",a,b,a-b);
break;
case '*' : printf("Multiplication is %d",a,b,a*b);
break;
case '/' : printf("Division is %d / %d = %f",a,b,(float)(a)/b);
break;
case '%' : printf("Modules %d % %d = %d",a,b,a%b);
break;
default : printf("Wrong action");
}
getch();
}
output
#include<conio.h>
main()
{
int a,b;
char operator;
clrscr();
printf("Enter A,B values:");
scanf("%d %d",&a,&b);
printf("Choose one of the operator\n");
printf(" + for addition \n - for subtraction \n * for multiply \n / for division \n \% modulus\n");
fflush(stdin);
scanf("%c",&operator);
switch(operator)
{
case '+' : printf("sum %d + %d= %d",a,b,a+b);
break;
case '-' : printf("Subtraction %d - %d = %d",a,b,a-b);
break;
case '*' : printf("Multiplication is %d",a,b,a*b);
break;
case '/' : printf("Division is %d / %d = %f",a,b,(float)(a)/b);
break;
case '%' : printf("Modules %d % %d = %d",a,b,a%b);
break;
default : printf("Wrong action");
}
getch();
}
output
Enter A,B values:
2 5
Choose one of the operator
+ for addition
- for subtraction
* for multiply
/ for division
% modulus
+
sum 2 + 5= 7
2 5
Choose one of the operator
+ for addition
- for subtraction
* for multiply
/ for division
% modulus
+
sum 2 + 5= 7
0 comments:
Post a Comment