:3

Dependencies:   mbed

Revision:
0:2792fd1649c8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NewCalc.cpp	Fri Aug 17 12:46:01 2018 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#define DEBUG 1
+Serial pc(SERIAL_TX,SERIAL_RX);
+int op1, op2, tp, r;
+void f_p(int n)
+{
+    int c=n/100;
+    int d=(n-(c*100))/10;
+    int u=(n-(c*100)-(d*10));
+    pc.putc(c+0x30);
+    pc.putc(d+0x30);
+    pc.putc(u+0x30);
+    }
+void debugm(int s)
+{ 
+    #if DEBUG
+    pc.printf("\n%d%",s);
+    #endif
+    }
+
+main()
+{
+    while(1)
+    {
+        op1=pc.getc();
+        pc.printf("\nIngrese el primero operador");
+        debugm(op1);
+        
+        op2=pc.getc();
+        pc.printf("\nIngrese el segundo operador");
+        debugm(op2);
+         
+        tp=pc.getc();
+        pc.printf("\nIngrese el numero de la operacion");
+        debugm(tp);
+        
+        switch(tp)
+        {
+            case 1:
+            r=op1*op2;
+            break;
+            
+            case 2:
+            r=op1/op2;
+            break;
+            
+            case 3:
+            r=op1+op2;
+            break;
+            
+            case 4:
+            r=op1-op2;
+            break;
+            }
+            //f_p(r);
+            pc.printf("\nEl resultado es..  ");
+            debugm(r);
+            }
+        }
\ No newline at end of file