Thanks for the replies . I really appreciate it. I've changed my code a bit according what oogabooga said.
Here it is:
Code:
#include <stdio.h>
#define absolute_zero -273
#define max_lim 50000
//Function that converts from degreeCelsius to degreeFahrenheit
float convert_to_degf(float deg_c)
{
float result = ((deg_c*9)/5)+32;
return result;
}
//The main function
int main()
{
//Variable declarations
float low_lim = -274.000000;
float high_lim = -275.000000;
int step = -1;
float i;
float result;
//Get the lower limit from user. Repeat if not within the range.
while(low_lim < absolute_zero)
{
printf("Please give in a lower limit, limit >= %d: ", absolute_zero);
scanf("%f", &low_lim);
}
//Get the higher limit from the user. Repeat if not within the range.
while(high_lim <= low_lim || high_lim > max_lim)
{
printf("Please give in a higher limit, %.1f < limit <= 50000: ", low_lim);
scanf("%f", &high_lim);
}
//Get the step from the user. Repeat if not within the range.
while(step <= 0 || step > high_lim-low_lim)
{
printf("Please give in a step, 0 < step <= %.1f: ", high_lim-low_lim);
scanf("%d", &step);
}
//Prints the table headings.
printf("\nCelsius Fahrenheit\n");
printf("------- ----------\n");
//Print the values till the next value is greater than the high limit.
for(i = low_lim; i <= high_lim; i += step)
{
result = convert_to_degf(i);
printf("%f %f\n", i, result);
}
//Wait for user to press a key
getch();
return 0;
}