Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4.  
  5. {
  6.  
  7. int num1, num2, result;
  8.  
  9. char operand;
  10.  
  11. printf ("\nEnter first number\n");
  12. scanf ("%d", &num1);
  13.  
  14. printf ("\nEnter second number\n");
  15. scanf ("%d", &num2);
  16.  
  17. printf ("\nWhat mathematical operation would you like to perform?\n");
  18.  
  19. printf ("\nEnter + to add");
  20. printf ("\nEnter - to substract");
  21. printf ("\nEnter * to multiply");
  22.  
  23. scanf("%c", &operand);
  24.  
  25. switch (operand)
  26. {
  27. case '+': result = num1 + num2;
  28. printf ("your addition yields =", result);
  29. break;
  30.  
  31. case '-': result = num1 - num2;
  32. printf ("your substraction yields =", result);
  33. break;
  34.  
  35. case '*': result = num1 * num2;
  36. printf ("your multiplication yields =", result);
  37. break;
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement