Calculator
This commit is contained in:
42
Calculator.c
Normal file
42
Calculator.c
Normal file
@@ -0,0 +1,42 @@
|
||||
// Write a menu driven program for calculator.
|
||||
|
||||
void main() {
|
||||
int num1,num2,opt;
|
||||
printf("Enter the first Integer :");
|
||||
scanf("%d",&num1);
|
||||
printf("Enter the second Integer :");
|
||||
scanf("%d",&num2);
|
||||
|
||||
printf("\nInput your option :\n");
|
||||
printf("1-Addition.\n2-Substraction.\n3-Multiplication.\n4-Division.\n5-Exit.\n");
|
||||
scanf("%d",&opt);
|
||||
switch(opt) {
|
||||
case 1:
|
||||
printf("The Addition of %d and %d is: %d\n",num1,num2,num1+num2);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
printf("The Subtraction of %d and %d is: %d\n",num1,num2,num1-num2);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
printf("The Multiplication of %d and %d is: %d\n",num1,num2,num1*num2);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if(num2==0) {
|
||||
printf("The second integer is zero. Divide by zero.\n");
|
||||
}
|
||||
else {
|
||||
printf("The Division of %d and %d is : %d\n",num1,num2,num1/num2);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Input correct option\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
BIN
Calculator.exe
Normal file
BIN
Calculator.exe
Normal file
Binary file not shown.
@@ -21,3 +21,4 @@
|
||||
|19 | Admission.c | Admission.exe | to find the eligibility of admission for a professional course based on the following criteria (Mentioned in file of the program) |
|
||||
|20 | QuadraticEquatic. | QuadraticEquatic.exe | WAP to calculate the root of a Quadratic Equation |
|
||||
|21 | Triangle.c | Triangle.exe | WAP to check whether a triangle can be formed by the given value for the angles |
|
||||
|22 | Calculator.c | Calculator.exe | Write a menu driven program for calculator |
|
||||
Reference in New Issue
Block a user