SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to find arithmetic operations using switch case
C program to find arithmetic operations using switch case
Output:
Enter the numbers followd by arithmetic operators(+,-,*,/,%):
Eg: 5 6 +
5 6 +
Sum = 11
Implementation:
#include
int main(void) { int a,b; char ch; printf("Enter the numbers followd by arithmetic operators(+,-,*,/,%):\n"); printf("Eg: 5 6 +\n"); scanf("%d %d %c",&a,&b,&ch); switch(ch) { case '+': printf("Sum = %d\n",(a+b)); break; case '-': printf("Difference = %d\n",(a-b)); break; case '/': printf("Division = %f\n",(float)(a/b)); break; case '*': printf("Multiplication = %d\n",(a*b)); break; case '%': printf("Modulo Division = %d\n",(a%b)); break; default: printf("Provide a valid Input:\n"); break; } return 0; }
PREVIOUS
NEXT
HOME