Last active
October 14, 2018 08:05
-
-
Save guemidiborhane/6489164011c1229b39e303b9e33a79dc to your computer and use it in GitHub Desktop.
This file contains 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> | |
int main(void) { | |
int a,b, op; | |
op = 5; | |
printf("Enter the value of A: "); | |
scanf("%i", &a); | |
printf("Enter the value of B: "); | |
scanf("%i", &b); | |
while(op != 0) { | |
printf("Select an operation:\n [0] To exit\n [1] For addition\n [2] For substraction\n [3] For multiplication\n [4] For division\nSelect your choice: [0,1,2,3,4]:"); | |
scanf("%i", &op); | |
switch(op) { | |
case 1: | |
printf("\nAnswer is : %i\n", a + b); | |
break; | |
case 2: | |
printf("\nAnswer is : %i\n", a - b); | |
break; | |
case 3: | |
printf("\nAnswer is : %i\n", a * b); | |
break; | |
case 4: | |
printf("\nAnswer is : %i\n", a / b); | |
break; | |
case 0: | |
printf("Goodbye !"); | |
break; | |
default: | |
printf("ERROR!! operation invalid.\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment