Calculator Using Switch Case |
In this program, you'll learn how to make a calculator in Java. Addition, Subtraction, Multiplication, Division all features are available in this c program. The final calculated result is displayed on the screen.
Calculator Program in C:
#include<stdio.h>int main() {
int num1,num2,opt;
printf("Enter the first Integer:\n");
scanf("%d",&num1);
printf("Enter the second Integer:\n");
scanf("%d",&num2);
for(;;) {
printf("\n\n\n\nPlease select your option:\n");
printf("O-Owner.\n1-Addition.\n2-Substraction.\n3-Multiplication.\n4-Division.\n5-Exit.\n");
scanf("%d",&opt);
switch(opt) {
case 0:
printf("Hanif Miah.\nMo-No:9547239503\nE-mail-codetextpro.com@gmail.com\nWhatapps No-9547239503");
break;
case 1:
printf("\nAddition of %d and %d is: %d",num1,num2,num1+num2);
break;
case 2:
printf("\nSubstraction of %d and %d is: %d",num1,num2,num1-num2);
break;
case 3:
printf("\nMultiplication of %d and %d is: %d",num1,num2,num1*num2);
break;
case 4:
if(num2==0) {
printf("OOps Devide by zero\n");
} else {
printf("\n Division of %d and %d is: %d",num1,num2,num1/num2);
}
break;
case 5:
return 0;
break;
default:
printf("\n Enter correct option\n");
break;
}
}
return 0;
}
Output:
Case0:
Case1:
Case2:
Case3:
Case4:
Case5:
0 Comments