c-first-steps

a C playground
Index Commits Files Refs README
commit aabc3780e72e11d2fe81acf0f1fc4bf3f7a6bd8b
parent 4b63152ebad97919a8a1590a3789f6cec494891c
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Thu, 19 Nov 2020 23:49:47 -0300

Added ej6.c - cuadratic formula roots calculator

Diffstat:
A95.11/guia01/ej6.c | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/95.11/guia01/ej6.c b/95.11/guia01/ej6.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <math.h>
+
+
+int main( void ) {
+
+    int a, b, c;
+    float x1, x2;
+    
+    a =  1;
+    b = -12;
+    c =  36;
+
+    x1 = ((-b) + sqrtf( (b*b)-(4*a*c) )) / (2*a);
+    x2 = ((-b) - sqrtf( (b*b)-(4*a*c) )) / (2*a);
+
+    printf("x1 = % .2f\nx2 = % .2f\n", x1, x2);
+
+    return 0;
+}