Skip to content

Instantly share code, notes, and snippets.

@guemidiborhane
Last active October 14, 2018 08:05
Show Gist options
  • Save guemidiborhane/6489164011c1229b39e303b9e33a79dc to your computer and use it in GitHub Desktop.
Save guemidiborhane/6489164011c1229b39e303b9e33a79dc to your computer and use it in GitHub Desktop.
#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