Use the following function for questions 1-5: // This function returns a 0 or 1.
ID: 3689842 • Letter: U
Question
Use the following function for questions 1-5:
// This function returns a 0 or 1.
int fives(int n)
{
int result;
if ((n%5) == 0)
{
return 1;
}
else
{
return 0;
}
}
1. Briefly describe what this fucntion does. (You can always write a quick main program that calls on the function!)
2. What is the value of fives(15)?
3. What is the value of fives(26)?
4. What is the value of fives(ceil(sqrt(62.5)))? Hint: ceil(x ) rounds x to the nearest integer towards infinity. You don't need a calculator to figure this out!
5. Does this function work properly for all integers? If not, what are its limitations?
for some reason i cant even get the code to work to answer the problems. please help
Explanation / Answer
2) fives(15) = 1
3) 0
1) If the n is form of 5n where n = 1,2,3... returns 1 else return 0.
* an extra check for 1 2 3 4 and -ive numbers.
5) Negative numbers and no less than 5 decimal no.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.