Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "rlutil.h"
  4.  
  5. #define FALSE 0
  6. #define TRUE 1
  7.  
  8. int main () {
  9.  
  10. int imprimir = TRUE;
  11.  
  12. int opcion;
  13. float a,b,r;
  14.  
  15. nuevointento:
  16. system("clear");
  17.  
  18. puts("PROGRAMA DE CALCULADORA BASICA ARITMETICA");
  19.  
  20. printf("Ingresa 2 numeros separados por un espacio");
  21. scanf("%f %f",&a,&b);
  22.  
  23. printf("Selecciona la opcion deseada:\n ");
  24. printf("1: SUMA\n");
  25. printf("2: RESTA\n");
  26. printf("3: MULTIPLICACION\n");
  27. printf("4: DIVISION\n");
  28. printf("---->");
  29. scanf("%d",&opcion);
  30.  
  31. switch(opcion) {
  32. case 1:
  33. r = a + b;
  34. break;
  35.  
  36. case 2:
  37. r = a - b;
  38. break;
  39.  
  40. case 3:
  41. r = a * b;
  42. break;
  43.  
  44. case 4:
  45. (b != 0.0)? (r = a / b) : (imprimir = (int)FALSE);
  46. break;
  47.  
  48. default:
  49. printf("Opcion no valida\n");
  50. getkey();
  51. goto nuevointento;
  52. break;
  53.  
  54. }
  55. if (imprimir = FALSE) {
  56. printf("Operacion invalida, division entre cero");
  57. }
  58. else {
  59. printf("El resultado es: %0.2f\n",r);
  60. }
  61.  
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement