commit 191867eefd9aeb4e550b4bd85ba79aeb3c314cd6
parent 64aae33d89f7c51c281f4e369fdaf91d2221cce1
Author: klewer-martin <martin.cachari@gmail.com>
Date: Sat, 6 Mar 2021 17:42:22 -0300
Update: Added ex03.c
Diffstat:
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/the-c-programming-language/chapter01/ex02.c b/the-c-programming-language/chapter01/ex02.c
@@ -4,7 +4,7 @@
int main( void ) {
- printf("Hello, world\n");
+ printf("\a\n");
return 0;
}
diff --git a/the-c-programming-language/chapter01/ex03.c b/the-c-programming-language/chapter01/ex03.c
@@ -0,0 +1,24 @@
+/* Exercise 1-3 - prints a table with degrees conversion */
+
+#include <stdio.h>
+
+
+int main (void)
+{
+ int lower, upper, step;
+ float c, f;
+
+/* Celsius values; */
+ lower = 0;
+ upper = 50;
+ step = 2;
+
+ printf("Celsius to Fahrenheit\n\n");
+
+ for(c = 0; c <= upper; c += step) {
+ f = (c * 9.0) / 5.0 + 32;
+ printf("%5.1f°C = %5.1f°F\n", c, f);
+ }
+
+ return 0;
+}