Gabriel Canseco Santana
/
FUNCIONESBASICAS_EQ7
Funciones básicas.
Revision 25:80f1d5b04bc6, committed 2019-10-09
- Comitter:
- gabocs
- Date:
- Wed Oct 09 03:49:31 2019 +0000
- Parent:
- 24:7f14b70fc9ef
- Commit message:
- Hola mundo
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7f14b70fc9ef -r 80f1d5b04bc6 main.cpp --- a/main.cpp Mon Apr 08 11:03:25 2019 +0100 +++ b/main.cpp Wed Oct 09 03:49:31 2019 +0000 @@ -1,12 +1,51 @@ #include "mbed.h" +Serial pc(USBTX,USBRX); +int funcion_suma(int, int); +int funcion_resta(int, int); +int funcion_mult(int, int); +float funcion_div(int, int); + -DigitalOut myled(LED1); +int funcion_suma(int x, int s) + { + int suma=x+s; + return suma; + } + +int funcion_resta(int x, int s) + { + int resta=x-s; + return resta; + } + +int funcion_mult(int x, int s) + { + int mult=x*s; + return mult; + } -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); +float funcion_div(int x, int s) + { + float div=x/s; + return div; } -} + + +int main(){ +char x; +int s, suma, resta, mult, div; + pc.printf("Ingrese un valor de un diito en su equivalencia ASCII (De no hacerlo su computadora explotara)"); + pc.printf("0=48\n\r 1=49 \n\r 2=50 \n\r 3=51 \n\r 4=52 \n\r 5=53 \n\r 6=54 \n\r 7=55 \n\r 8=56 \n\r 9=57"); + pc.putc(pc.getc()); + x=pc.getc(); +suma=funcion_suma(x,s); +resta=funcion_resta(x,s); +mult=funcion_mult(x,s); +div=funcion_div(x,s); + + pc.printf("La suma es: %d\r\n",suma); + pc.printf("La resta es %d\r\n",resta); + pc.printf("El producto es: %d\r\n",mult); + pc.printf("La division es:%d\r\n",div); + +} \ No newline at end of file