Created
January 11, 2023 16:14
-
-
Save sagarbangade/db2254b8ae5710811215ce94dc154619 to your computer and use it in GitHub Desktop.
Calculator in C language using Switch case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
printf("CalculatorS"); | |
int a,b; | |
printf("Enter first number: "); | |
scanf("%d",&a); | |
printf("Enter second number: "); | |
scanf("%d",&b); | |
char c; | |
printf("Enter which type of calculation you want: "); | |
scanf(" %c",&c); | |
switch(c) | |
{ | |
case '+': | |
printf("addition of %d + %d = %d",a,b,a+b); | |
break; | |
case '-': | |
printf("substraction of %d - %d = %d",a,b,a-b); | |
break; | |
case '*': | |
printf("multiplication of %d * %d = %d",a,b,a*b); | |
break; | |
case '/': | |
printf("division of %d / %d = %d",a,b,a/b); | |
break; | |
default: | |
printf("invalid"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment