So, I have a homework assignment with a part with instructions as follows:
Part 1: Write a function called get_value() that prompts the user toenter a value of type double between 0.0 and 10,000.0. If the user correctlyenters a value in this range, then the value is returned to the calling function.Otherwise, a value of -1 is returned.
So, I wrote the following program:
Code:
#include <stdio.h>
double get_value()
{
double value = 0.0;
printf("Enter a value of type double between 0.0 and 10,000.0: ");
scanf("%d", &value);
if ((value > 0) && (value < 10000))
printf("%d\n", value);
else
value = -1;
printf("%d", value);
}
int main()
{
get_value();
return 0;
}
I'm not entirely sure what I'm doing wrong here. Whatever value I enter, it simply outputs it to the screen like the if-else statement doesn't even exist. Any help is greatly appreciated.