Question: Copy your temptbl.c file from your Lab4 directory into your Lab5 directory. Modify your temptable() function to be: ********note/question at bottom. Thank You int temptable(float
Copy your temptbl.c file from your Lab4 directory into your Lab5 directory. Modify your temptable() function to be:
********note/question at bottom. Thank You
int temptable(float start, float stop, float step); /* Given: starting and ending temperatures in degrees Fahrenheit and a step size. The function prints a table of conversions from degrees Fahrenheit to degrees Celsius from start to at most stop in "step" degree F increments, one conversion per line. Returns: the number of table lines printed. */
The new function, temptable(), should still use your function, tocelsius(). Its job is to print an appropriate temperature table. The catch is that this function should work correctly, regardless of whether the first temperature is larger than the second or the second is larger than the first. In addition, it should not behave badly (go into an infinite loop) with a very small step (such as 0.0); that means for this lab that it should produce an error message "No table--step smaller than 0.001!" if the step is smaller than 0.001. If the step is negative, the function should turn it into a positive step. The call
temptable(32.0, 64.0, 4.0)
should produce this output:
Fahrenheit Celsius 32.00 0.00 36.00 2.22 40.00 4.44 44.00 6.67 48.00 8.89 52.00 11.11 56.00 13.33 60.00 15.56 64.00 17.78 Computed 9 temperatures
The call
temptable(42.0, 32.0, 5.0);
or the call
temptable(42.0, 32.0, -5.0);
should produce this output:
Fahrenheit Celsius 42.00 5.56 37.00 2.78 32.00 0.00 Computed 3 temperatures
Finally, replace the main program in temptbl.c with a new main program that repeatedly reads the temperatures and the step from the user and then uses the temptable function to print the table. As an example, here's a sample run of the program.
Enter start, stop and step:32 64 4 Fahrenheit Celsius 32.00 0.00 36.00 2.22 40.00 4.44 44.00 6.67 48.00 8.89 52.00 11.11 56.00 13.33 60.00 15.56 64.00 17.78 Computed 9 temperatures Enter start, stop and step:42 32 5 Fahrenheit Celsius 42.00 5.56 37.00 2.78 32.00 0.00 Computed 3 temperatures Enter start, stop and step:42 32 -5 Fahrenheit Celsius 42.00 5.56 37.00 2.78 32.00 0.00 Computed 3 temperatures [control-D]
This is the file from temptbl.c
********This program needs help too. If possible, can you please help modify the original code before the modification of the new material. Thank you, im really struggling with this!
scanf("%d", degrees);
/* compute degreees in celcius from fahreneheit */
Celcius= ( Fahrenheit - 32) * (5/9);
/* Given: a temperature reading in degrees Fahrenheit Returns: the temperature in degrees Celsius */
/* Given: starting and ending temperatures in degrees Fahrenheit The function prints a table of conversions from degrees Fahrenheit to degrees Celsius from start to at most stop in five degree F increments, one conversion per line. Returns: the number of table lines printed. */
/* print results */
printf(" %d Celcius ");
printf();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
