Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "rlutil.h"
- #define FALSE 0
- #define TRUE 1
- int main () {
- int imprimir = TRUE;
- int opcion;
- float a,b,r;
- nuevointento:
- system("clear");
- puts("PROGRAMA DE CALCULADORA BASICA ARITMETICA");
- printf("Ingresa 2 numeros separados por un espacio");
- scanf("%f %f",&a,&b);
- printf("Selecciona la opcion deseada:\n ");
- printf("1: SUMA\n");
- printf("2: RESTA\n");
- printf("3: MULTIPLICACION\n");
- printf("4: DIVISION\n");
- printf("---->");
- scanf("%d",&opcion);
- switch(opcion) {
- case 1:
- r = a + b;
- break;
- case 2:
- r = a - b;
- break;
- case 3:
- r = a * b;
- break;
- case 4:
- (b != 0.0)? (r = a / b) : (imprimir = (int)FALSE);
- break;
- default:
- printf("Opcion no valida\n");
- getkey();
- goto nuevointento;
- break;
- }
- if (imprimir = FALSE) {
- printf("Operacion invalida, division entre cero");
- }
- else {
- printf("El resultado es: %0.2f\n",r);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement