Practica 7

Dependencies:   mbed

Committer:
isaacross99
Date:
Wed Oct 09 02:53:15 2019 +0000
Revision:
28:868b283c5f77
Parent:
27:eb32f100130f
Child:
29:734b61eca6df
0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dan 0:7dec7e9ac085 1 #include "mbed.h"
rgsbuap 26:29f649949409 2 Serial pc(USBTX,USBRX);
isaacross99 28:868b283c5f77 3 int suma(int,int);
isaacross99 28:868b283c5f77 4 int resta(int,int);
isaacross99 28:868b283c5f77 5 int producto(int,int);
isaacross99 28:868b283c5f77 6 float division(int,int);
isaacross99 28:868b283c5f77 7 int main(void){
isaacross99 28:868b283c5f77 8 int digito_1, digito_2;
isaacross99 28:868b283c5f77 9 pc.printf("Ingrese un digito: ");
isaacross99 28:868b283c5f77 10 digito_1 = pc.getc();
isaacross99 28:868b283c5f77 11 switch(digito_1){
isaacross99 28:868b283c5f77 12 case '0': digito_1 = 0;
isaacross99 28:868b283c5f77 13 break;
isaacross99 28:868b283c5f77 14 case '1': digito_1 = 1;
isaacross99 28:868b283c5f77 15 break;
isaacross99 28:868b283c5f77 16 case '2': digito_1 = 2;
isaacross99 28:868b283c5f77 17 break;
isaacross99 28:868b283c5f77 18 case '3': digito_1 = 3;
isaacross99 28:868b283c5f77 19 break;
isaacross99 28:868b283c5f77 20 case '4': digito_1 = 4;
isaacross99 28:868b283c5f77 21 break;
isaacross99 28:868b283c5f77 22 case '5': digito_1 = 5;
isaacross99 28:868b283c5f77 23 break;
isaacross99 28:868b283c5f77 24 case '6': digito_1 = 6;
isaacross99 28:868b283c5f77 25 break;
isaacross99 28:868b283c5f77 26 case '7': digito_1 = 7;
isaacross99 28:868b283c5f77 27 break;
isaacross99 28:868b283c5f77 28 case '8': digito_1 = 8;
isaacross99 28:868b283c5f77 29 break;
isaacross99 28:868b283c5f77 30 case '9': digito_1 = 9;
isaacross99 28:868b283c5f77 31 break;
isaacross99 28:868b283c5f77 32 default: pc.printf("\n\nValor invalido.");
isaacross99 28:868b283c5f77 33 }
isaacross99 28:868b283c5f77 34 digito_2 = 5;
isaacross99 28:868b283c5f77 35 pc.printf("\n\nSuma = %d \nResta = %d \nProducto = %d \nDivision = %f", suma(digito_1,digito_2), resta(digito_1,digito_2), producto(digito_1,digito_2), division(digito_1,digito_2));
rgsbuap 26:29f649949409 36 }
isaacross99 28:868b283c5f77 37 int suma(int digito_1,int digito_2){
isaacross99 28:868b283c5f77 38 int suma = digito_1 + digito_2;
isaacross99 28:868b283c5f77 39 return suma;
isaacross99 28:868b283c5f77 40 }
isaacross99 28:868b283c5f77 41 int resta(int digito_1,int digito_2){
isaacross99 28:868b283c5f77 42 int resta = digito_1 - digito_2;
isaacross99 28:868b283c5f77 43 return resta;
rgsbuap 26:29f649949409 44 }
isaacross99 28:868b283c5f77 45 int producto(int digito_1,int digito_2){
isaacross99 28:868b283c5f77 46 int producto = digito_1 * digito_2;
isaacross99 28:868b283c5f77 47 return producto;
isaacross99 28:868b283c5f77 48 }
isaacross99 28:868b283c5f77 49 float division(int digito_1,int digito_2){
isaacross99 28:868b283c5f77 50 float division = digito_1 / digito_2;
isaacross99 28:868b283c5f77 51 return division;
isaacross99 28:868b283c5f77 52 }