Enter two positive integers lower and upper (lower≤upper≤100), make an output range of [lower, upper], and increments of 2 ° F Fahrenheit - Celsius conversion table.
Temperature conversion formula: C = 5 × (F-32) / 9, wherein: C represents temperature in degrees Celsius, F represents Fahrenheit.
Input formats:
2 on a single line an integer, represent the values of the lower and upper, separated by spaces.
Output formats:
The first line of output: "fahr celsius"
Then each row outputs a Fahr Fahrenheit (integer) and a Celsius Celsius (6 characters occupying width, right justified, Reserved 1 decimal).
If the range entered is not valid, the output "Invalid.".
Sample Input 1:
32 35
Output Sample 1:
driving celsius
32 0.0
34 1.1
Sample Input 2:
40 30
Output Sample 2:
Invalid.
#include<stdio.h>
int main()
{
int a, b, f;
float c;
scanf("%d %d", &a, &b);
if (a>b) {
printf("Invalid.\n");
}
else
{
printf("fahr celsius\n");
for (f = a; f <= b; f += 2) {
c = 5 * (f * 1.0 - 32) / 9;
printf("%d%6.1f\n", f, c);
}
}
return 0;
}