W
whojustdenyme
Hey guys, I'm new to C and programming..so I need some help.
I need a way to round an INPUT number to an INPUT value
so for ex:
enter a decimal: 3.1459
enter the number to round: 3
Answer: 3.146
Here's what I have so far...
#include<stdio.h>
#include<math.h>
int main()
{
float decVal; //DECIMAL VALUE
int round; //# OF PLACES TO ROUND
float a; //ANSWER AFTER ROUNDING
printf("Enter a number as a decimal value (ie. 3.1459): ");
scanf("%f", &decVal);
printf("Enter the number of places to round (ie. 3): ");
scanf("%d", &round);
printf("The number %f rounded to %d decimal places is %f", decVal,
round);
return(0);
}
I need a way to round an INPUT number to an INPUT value
so for ex:
enter a decimal: 3.1459
enter the number to round: 3
Answer: 3.146
Here's what I have so far...
#include<stdio.h>
#include<math.h>
int main()
{
float decVal; //DECIMAL VALUE
int round; //# OF PLACES TO ROUND
float a; //ANSWER AFTER ROUNDING
printf("Enter a number as a decimal value (ie. 3.1459): ");
scanf("%f", &decVal);
printf("Enter the number of places to round (ie. 3): ");
scanf("%d", &round);
printf("The number %f rounded to %d decimal places is %f", decVal,
round);
return(0);
}