1
0
mirror of https://github.com/krislamo/knrc.git synced 2024-09-19 21:00:35 +00:00

Compare commits

...

3 Commits

3 changed files with 17 additions and 2 deletions

View File

@ -1,11 +1,15 @@
#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20
/* print Fahrenheit-Celsius table */
int main()
{
int fahr;
printf("Fahrenheit\tCelsius\n=======================\n");
for (fahr = 0; fahr <= 300; fahr = fahr + 20)
for (fahr = UPPER; fahr >= LOWER; fahr = fahr - STEP)
printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32));
}

View File

@ -1,11 +1,15 @@
#include <stdio.h>
#define LOWER 0
#define UPPER 300
#define STEP 20
/* print Celsius-Fahrenheit table */
int main()
{
int cels;
printf("Celsius\t\tFahrenheit\n==========================\n");
for (cels = 0; cels <= 300; cels = cels + 20)
for (cels = LOWER; cels <= UPPER; cels = cels + STEP)
printf("%3d\t\t%10.0f\n", cels, (9.0/5.0)*cels+32);
}

View File

@ -145,3 +145,10 @@ https://github.com/krislamo/knrc/commit/93126a8207ba83e3712bbab7b1e54548761a5fa1
https://github.com/krislamo/knrc/blob/93126a8207ba83e3712bbab7b1e54548761a5fa1/03-celsius-to-fahrenheit.c[(Source)]
This is a simple little solution for a Celsius to Fahrenheit table.
Exercise 1-5. print the table in reverse order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
https://github.com/krislamo/knrc/commit/588969b09fabab1e91ff4f4b1c37e87fc23cf76b[(Diff)]
https://github.com/krislamo/knrc/blob/588969b09fabab1e91ff4f4b1c37e87fc23cf76b/02-vars-and-math.c[(Source)]
Move some numbers around to reverse the table.