Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- More info--
- This is for an assignment in which I must use the floor() function to round a variable "number" to
- various accuracies. When I try to compile I get:
- Error: Conflicting types of (every function starting with round)
- Previous declaration of (function starting with round) was here
- Error: Too few arguments to function (starting with round)
- Any help would be greatly appreciated! Thank you in advance.
- **/
- #include <stdio.h>
- #include <math.h>
- float number=0, roundedInteger=0, roundedTenth=0, roundedHundredth=0, roundedThousandth=0; //global variables
- float roundToInteger(float roundedInteger), roundToTenth(float roundedTenth), roundToHundredth(float roundedHundredth), roundToThousandth(float roundedThousandth); //function protos
- int main()
- {
- printf("This program takes a decimal and rounds it to different levels.\nEnter the number to be rounded.");
- scanf("%f", &number);
- printf("Rounded to nearest integer: %f", roundToInteger()); // calls the function to find rounded number
- printf("Rounded to nearest tenth: %f", roundToTenth()); // calls the function to find rounded number
- printf("Rounded to nearest hundredth: %f", roundToHundredth()); // calls the function to find rounded number
- printf("Rounded to nearest thousandth: %f", roundToThousandth()); // calls the function to find rounded number
- return 0;
- }
- roundToInteger()
- {
- roundedInteger=(floor(number)/1);
- return (roundedInteger);
- }
- roundToTenth()
- {
- roundedTenth=(floor(number)/10);
- return (roundedTenth);
- }
- roundToHundredth()
- {
- roundedHundredth=(floor(number)/100);
- return (roundedHundredth);
- }
- roundToThousandth()
- {
- roundedThousandth=(floor(number)/1000);
- return (roundedThousandth);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement