Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C PROGRAM Temptbl.c File (2 Points). Copy your temptbl.c file from your Lab4 directory into your Lab5 directory. Modify your temptable() function to be:

IN C PROGRAM

image text in transcribedimage text in transcribed

Temptbl.c File

image text in transcribed

(2 Points). Copy your temptbl.c file from your Lab4 directory into your Lab5 directory. Modify your temptable() function to be: 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: 2.22 Fahrenheit Celsius 32.00 0.00 36.00 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 52.00 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] #include double tocelsius (int F) { return (F - 32)* 5 / 9; int temptable (float start, float stop) { int incr = 5; int count = 0; while (start

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions