c-first-steps

a C playground
Index Commits Files Refs README
commit b89885d81084965d3e8f196814fb034a8f04bcda
parent ce4ad8eac071003393907010f3f94fb4ac40e364
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Thu, 29 Oct 2020 20:06:41 -0300

Added comments to improve code readability

Diffstat:
Msrc/dc.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/dc.c b/src/dc.c
@@ -9,15 +9,16 @@ typedef enum {
     CELSIUS
 } escala_t;
 
-typedef float dato_t;
+typedef float dato_t;    //    this statement is not practical at all
+                        //    but was part of the intro to typedef
 
 char s[10];
 
-float ftoc(dato_t fahrenheit) {
+dato_t ftoc(dato_t fahrenheit) {
     return (((fahrenheit - 32)*5)/9);
 }
 
-float ctof(dato_t celsius) {
+dato_t ctof(dato_t celsius) {
     return (((celsius * 9)/5) + 32);
 }
 
@@ -55,7 +56,7 @@ int main(void)
     if(c == FAHRENHEIT) {
         title_ftoc();
         dato_t i;
-        float res;
+        dato_t res;
         while(fgets(s, 10, stdin) != NULL) {
             i = atoi(s);
             res = ftoc(i);
@@ -65,7 +66,7 @@ int main(void)
     } else if(c == CELSIUS) {
         title_ctof();
         dato_t i;
-        float res;
+        dato_t res;
         while(fgets(s, 10, stdin) != NULL) {
             i = atoi(s);
             res = ctof(i);