
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This c program allows users to perform addition, subtraction, multiplication, division, and modulus operations by inputting their choice and two numbers.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

1 #include <stdio.h> 2 3 int main() 4 { 5 char ch; 6 int a,b; 7 8 printf("Add\nSub\nMul\nDiv\nmOd\nEnter your choice:"); 9 ch = getchar(); 10 11 printf("Enter the two numbers :"); 12 scanf("%d%d",&a,&b); 13 14 switch(ch){ 15 case 'A': 16 case 'a': 17 printf("Sum = %d\n",a+b); 18 break; 19 case 'S': 20 case 's': 21 printf("Dif = %d\n",a-b); 22 break; 23 case 'M': 24 case 'm': 25 printf("Pro = %d\n",a*b); 26 break; 27 case 'D': 28 case 'd': 29 printf("Quo = %d\n",a/b); 30 break; 31 case 'O': 32 case 'o': 33 printf("Rem = %d\n",a%b); 34 break; 35 default: 36 printf("Please choose a valid option\n"); 37 } 38 39 } 40