mirror of
https://github.com/krislamo/knrc.git
synced 2024-11-10 00:30:35 +00:00
Compare commits
3 Commits
ee5bcb81ce
...
fe248c5a30
Author | SHA1 | Date | |
---|---|---|---|
fe248c5a30 | |||
f88aa3d25f | |||
588969b09f |
@ -1,11 +1,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LOWER 0
|
||||||
|
#define UPPER 300
|
||||||
|
#define STEP 20
|
||||||
|
|
||||||
/* print Fahrenheit-Celsius table */
|
/* print Fahrenheit-Celsius table */
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int fahr;
|
int fahr;
|
||||||
|
|
||||||
printf("Fahrenheit\tCelsius\n=======================\n");
|
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));
|
printf("%3d\t\t%7.1f\n", fahr, (5.0/9.0)*(fahr-32));
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define LOWER 0
|
||||||
|
#define UPPER 300
|
||||||
|
#define STEP 20
|
||||||
|
|
||||||
/* print Celsius-Fahrenheit table */
|
/* print Celsius-Fahrenheit table */
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int cels;
|
int cels;
|
||||||
|
|
||||||
printf("Celsius\t\tFahrenheit\n==========================\n");
|
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);
|
printf("%3d\t\t%10.0f\n", cels, (9.0/5.0)*cels+32);
|
||||||
}
|
}
|
||||||
|
@ -145,3 +145,10 @@ https://github.com/krislamo/knrc/commit/93126a8207ba83e3712bbab7b1e54548761a5fa1
|
|||||||
https://github.com/krislamo/knrc/blob/93126a8207ba83e3712bbab7b1e54548761a5fa1/03-celsius-to-fahrenheit.c[(Source)]
|
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.
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user