i am making a simple program that is suppose to round numbers off. How do you convert a float value to an integer value???
and then i got this error that saids:
cc: "round.c", line 52: error 1535: % operator takes integral operands.
on line 52 i try to modulate my float value by 1----- remin = value % 1;
what does that error mean??
here is my program if you wanna check it out:
*/
/* This Program Rounds A Float Value To the Nearest Integer */
int main()
{
/* Declare Variables */
int round_value;
float value;
int round_to_int(float value);
/* Prompt the user for a float value */
printf("Please Enter A Float Value (0 to quit): ");
scanf("%f", &value);
/* while loop when value not equal to 0 */
while (value != 0)
{
/* call function round_to_int */
round_value = round_to_int(value);
/* print the results */
printf("rounding %f yields %d", value, round_value);
}
}
/* function round_to_int */
int round_to_int(float value)
{
/* declare round_to_int function variables */
int round_value;
int remin;
/* determining the reminder */
remin = value % 1.0;
/* if statements */
if(remin >= 5)
round_value = value + 1;
else
round_value = round_value;
/* return round_value */
return round_value;
}
and then i got this error that saids:
cc: "round.c", line 52: error 1535: % operator takes integral operands.
on line 52 i try to modulate my float value by 1----- remin = value % 1;
what does that error mean??
here is my program if you wanna check it out:
*/
/* This Program Rounds A Float Value To the Nearest Integer */
int main()
{
/* Declare Variables */
int round_value;
float value;
int round_to_int(float value);
/* Prompt the user for a float value */
printf("Please Enter A Float Value (0 to quit): ");
scanf("%f", &value);
/* while loop when value not equal to 0 */
while (value != 0)
{
/* call function round_to_int */
round_value = round_to_int(value);
/* print the results */
printf("rounding %f yields %d", value, round_value);
}
}
/* function round_to_int */
int round_to_int(float value)
{
/* declare round_to_int function variables */
int round_value;
int remin;
/* determining the reminder */
remin = value % 1.0;
/* if statements */
if(remin >= 5)
round_value = value + 1;
else
round_value = round_value;
/* return round_value */
return round_value;
}