/ Published in: C
New Fuctions
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Includes of the System #include <stdio.h> #include <inttypes.h> #include <math.h> // Float variables of numbers float a = 0; float b = 0; // Float variable of result float result = 0; // Check Variable uint8_t lastresult = 0; // Define PI #define PI 3.14159265 /* Fuction AskNumbers Ask for the numbers */ void AskNumbers () { if (lastresult == 0 ) { } else if (lastresult == 1) { a = result; } else if (lastresult == 2) { b = result; } } /* Fuction PrintfOptions Printf the Options */ void PrintfOptions () { } /* Main Init point of System */ int main() { // Temporal vairables uint8_t salir = 0; uint8_t opcion = 0; // Main While while(salir == 0) { // Printf the Options PrintfOptions(); // Ask for the option // Check if answer is correct if (opcion > 0 && opcion < 6) AskNumbers(); else if (opcion >= 6 && opcion < 9) { if (lastresult == 0 ) { } else { a = result; } } // Make the operation switch (opcion) { case 1: result = a + b; break; case 2: result = a - b; break; case 3: result = a * b; break; case 4: result = a / b; break; case 5: result = a; for (float i = 0; i < b-1; i++) result *= a; break; case 6: break; case 7: break; case 8: break; default: break; } // Ask for go out // Check the answer if (opcion == 1) salir = 1; else { salir = 0; if (opcion == 1) lastresult = 1; else if (opcion == 2) lastresult = 2; else lastresult = 0; } // New Line } // Exit of the program return 0; }