C Program for Temperature Conversion from Celsius to Fahrenheit.
K&R C Program Exercise 1-04 Problem :
Write a program to print the corresponding Celsius to Fahrenheit table.
C Program : Temperature Conversion from Celsius to Fahrenheit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include<stdio.h> int main() { float fahrenheit, celsius; int lower, upper, step; lower = 0; upper = 200; step = 20; printf(" C\tF"); printf("\n------------"); celsius = lower; while (celsius <= upper) { fahrenheit = (9.0 / 5.0) * celsius + 32.0; printf("\n%3.0f %6.1f", celsius, fahrenheit); celsius = celsius + step; } return 0; } |
Output of Program :
1 2 3 4 5 6 7 8 9 10 11 12 13 | C F ------------ 0 32.0 20 68.0 40 104.0 60 140.0 80 176.0 100 212.0 120 248.0 140 284.0 160 320.0 180 356.0 200 392.0 |