Advertisement
gtw7375

QUESTION 4 - PORTUGAL

Sep 3rd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. main() {
  2. int num1, num2, opcao, soma;
  3.  
  4. printf("Digite a opcao desejada. \n 1-Multiplicar \n 2-Somar \n 3-Subtrair \n 4-Dividir \n 5-Sair");
  5. scanf("%d", &opcao);
  6.  
  7. while(opcao !=5 ) {
  8.  
  9. printf("Digite o primeiro numero");
  10. scanf("%d", &num1);
  11.  
  12. printf("Digite o segundo numero");
  13. scanf("%d", &num2);
  14.  
  15. switch(opcao) {
  16.  
  17. case 1:
  18.  
  19.  
  20.  
  21. soma = num1 * num2;
  22.  
  23. printf("%d", soma);
  24. break;
  25.  
  26. case 2:
  27.  
  28.  
  29. soma = num1 + num2;
  30.  
  31. printf("%d", soma);
  32. break;
  33.  
  34. case 3:
  35.  
  36.  
  37.  
  38. soma = num1 - num2;
  39.  
  40. printf("%d", soma);
  41. break;
  42. case 4:
  43.  
  44.  
  45.  
  46. soma = num1 / num2;
  47.  
  48. printf("%d", soma);
  49. break;
  50. default :
  51. printf("Operação invalida");
  52. }
  53. printf("Digite a opcao desejada. \n 1-Multiplicar \n 2-Somar \n 3-Subtrair \n 4-Dividir \n 5-Sair");
  54. scanf("%d", &opcao);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement