123k views
2 votes
Please enter a low limit (limit >= 0): 10 Please enter a high limit (10 > limit <= 50000): 20 Please enter a step, (0 < step <= 10): 4 Celsius Fahrenheit ------- ---------- A. 10.000000 50.000000 B. 14.000000 57.200000 C. 18.000000 64.400000

User Selena
by
5.3k points

1 Answer

3 votes

Answer:

Following are the program in the C Programming Language.

//define header file

#include <stdio.h>

//define constant

#define LowerLimit 0

//define constant

#define HigherLimit 50000

//define main method

int main(void) {

//set double type variables

double fahrenheit, celsius;

int low = -1;

int high = -1;

int step = -1;

int max_steps = 0;

//set while loop which reads lower limit

while(low<(int) LowerLimit) {

printf("Please give in a lower limit, limit >= %d: ", (int)LowerLimit);

scanf("%d", &low);

}

//set while loop which reads higher limit

while((high<=low)||(high>(int) HigherLimit)) {

printf("Please give in a higher limit, %d < limit <= %d: ",low,(int)HigherLimit);

scanf("%d", &high);

}

//set while loop which reads steps

max_steps =high-low;

while((step <= 0) || (step > max_steps)) {

printf("Please give in a step, 0 < step >= %d: ", max_steps);

scanf("%d", &step);

}

//initialize the value of low in celsius

celsius =low;

//print the following table

printf("\\Celsius\t\tFahrenheit");

printf("\\-------\t\t----------\\");

//set while loop

while(celsius<=high) {

fahrenheit = (9.0 * celsius) / 5.0 + 32.0;

printf("%f\t%f\\", celsius, fahrenheit);

celsius += step;

}

return 0;

}

Step-by-step explanation:

Here, we define a main() function inside it.

Set two double data type variables and two integer type variables.

  • Set the while loop that reads the lower limit from the user with a message.
  • Again set the while loop that reads the higher limit from the user with message.
  • We set the while loop that reads the steps from the user with a message.
  • Initialize the value stored in the variable low into the variable celsius then, print the format of a table with the help of print() function.
  • Finally, set the while loop which calculates the value of Fahrenheit and print the value of Celsius and Fahrenheit.
User Daniex
by
5.3k points