# Arithmetic calculator using switch statement

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#include<stdio.h> #include<conio.h> void main() { int choice, no1, no2, result; clrscr(); printf("\n\n*********************"); printf("\nArithmetic Calculator"); printf("\n*********************"); printf("\n\n1. Addition\n2. Subtraction"); printf("\n3. Multiplication\n4. Division"); printf("\n\nEnter your choice: "); scanf("%d",&choice); switch(choice){ case 1: printf("\nEnter the two number:"); scanf("%d %d", &no1, &no2); result = no1 + no2; printf("\nThe Addition of %d and %d is %d", no1, no2, result); break; case 2: printf("\nEnter the two number:"); scanf("%d %d", &no1, &no2); result = no1 - no2; printf("\nThe Subtaction of %d and %d is %d", no1, no2, result); break; case 3: printf("\nEnter the two number:"); scanf("%d %d", &no1, &no2); result = no1 * no2; printf("\nThe Multiplication of %d and %d is %d", no1, no2, result); break; case 4: printf("\nEnter the numerator and denominator:"); scanf("%d %d", &no1, &no2); if(no2 == 0){ printf("\nError: cannot divide by zero"); } else{ result = no1 / no2; printf("\nDivision of %d by %d is %d", no1, no2, result); } break; } getch(); } |

**Output:**

1 2 3 4 5 6 7 8 9 10 |
********************* Arithmetic Calculator ********************* 1. Addition 2. Subtraction 3. Multiplication 4. Division Enter your choice: 4 Enter the numerator and denominator:5 0 Error: cannot divide by zero |

now where’s your division ? if denominator is not zero..:)

Thanks buddy… ðŸ™‚

I really like your working.

i like it.

amazing

its nice nd easy to learn

you r good

you do best

Thanks .. nice program for beginners.