I kind of have this one worked out, somewhat. What I'm trying to do, is create a table using a for loop. The table will have Celsius from 0 to 100 and a table for Farenheit 32 to 212.
Here's what I got:
Code:
/* This program prints out a conversion table for Celsuis to Farenheit (0 to 100) and Farenheit to Celsius (32 to 212).
Written by:
*/
#include <stdio.h>
#define Conversion_Factor (100.0 / 180.0)
int main (void)
{
/* Local Definitions */
float x;
float y;
/* Statements */
printf(" Farenheit Conversion Table\n");
for ( x = 0; x <= 100; x++)
{
/* Centigrade to Farenheit */
printf("%.2f\t", (Conversion_Factor * x) + 32);
}
printf("\n");
return 0;
}
/* main */
/* Results */
The results I get are the following, which is almost right except my ending value doesn't quite make it to 212, for some odd reason.
Code:
Farenheit Conversion Table
32.00 32.56 33.11 33.67 34.22 34.78 35.33 35.89 36.44 37.00
37.56 38.11 38.67 39.22 39.78 40.33 40.89 41.44 42.00 42.56
43.11 43.67 44.22 44.78 45.33 45.89 46.44 47.00 47.56 48.11
48.67 49.22 49.78 50.33 50.89 51.44 52.00 52.56 53.11 53.67
54.22 54.78 55.33 55.89 56.44 57.00 57.56 58.11 58.67 59.22
59.78 60.33 60.89 61.44 62.00 62.56 63.11 63.67 64.22 64.78
65.33 65.89 66.44 67.00 67.56 68.11 68.67 69.22 69.78 70.33
70.89 71.44 72.00 72.56 73.11 73.67 74.22 74.78 75.33 75.89
76.44 77.00 77.56 78.11 78.67 79.22 79.78 80.33 80.89 81.44
82.00 82.56 83.11 83.67 84.22 84.78 85.33 85.89 86.44 87.00
87.56
Press any key to continue
As for the other way around Farenheit to Centigrade, I have coded it the following way, but when I added it to the end of the previous code, it stops and doesn't execute.
Code:
printf("Centigrade Conversion Table\n");
for( y = 32; y <= 212; y++)
{
/* Farenheit to Centigrade */
printf("%.2f\t", Conversion_Factor * (y - 32);
}
printf("\n");
TIA, for any help or suggestions that you can provide.