Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, opt;
clrscr();
printf("Enter any Two Numbers : ");
scanf("%d%d", &a, &b);
printf("1-Addition\n2-Subtraction\n3-Multiplication\n4-Division\n5-Modulus\nEnter Your Option :");
scanf("%d", &opt);
switch(opt)
{
case 1:
printf("Addition of %d and %d is %d", a, b, a+b);
break;
case 2:
printf("Subtraction of %d and %d is %d", a, b, a-b);
break;
case 3:
printf("Multiplication of %d and %d is %d", a, b, a*b);
break;
case 4:
printf("Division of %d and %d is %d", a, b, a/b);
break;
case 5:
printf("Modulus of %d and %d is %d", a, b, a%b);
break;
default:
printf("Invalid Option");
}
getch();
}
Output:
Ex-1:
Enter any Two Numbers : 20 10
1-Addition
2-Subtraction
3-Multiplication
4-Division
5-Modulus
Enter Your Option : 1
Addition of 20 and 10 is 30
Ex-2:
Enter any Two Numbers : 20 10
1-Addition
2-Subtraction
3-Multiplication
4-Division
5-Modulus
Enter Your Option : 2
Subtraction of 20 and 10 is 10
Ex-3:
Enter any Two Numbers : 20 10
1-Addition
2-Subtraction
3-Multiplication
4-Division
5-Modulus
Enter Your Option : 3
Multiplication of 20 and 10 is 200
Ex-4:
Enter any Two Numbers : 20 10
1-Addition
2-Subtraction
3-Multiplication
4-Division
5-Modulus
Enter Your Option : 4
Division of 20 and 10 is 2
Ex-5:
Enter any Two Numbers : 20 10
1-Addition
2-Subtraction
3-Multiplication
4-Division
5-Modulus
Enter Your Option : 5
Modulus of 20 and 10 is 0
Next Topic :
Previous Topic :
No comments:
Post a Comment