In: Computer Science
Create your own function in C that accepts one input number and returns a double number. The themes for the functions should be one of the following:
Divides the number by 3 and returns the result. For example, if 6 was input then 2.0 should be returned.
provide both your C code and an example call to the C code function. Be sure to provide an overview of what your function is doing. Include header documentation in the code as well as internal code documentation.
Code:
#include <stdio.h>
/**
* Divides the input number by 3.
*
* @param int number Input from the caller.
*
* @return double Return value after dividing input by 3.
*
*/
double divideby3(int number){
// divides the number by 3 and returns the output
return (double)(number)/3.0;
}
int main()
{
// call the function divideby3 and print the output
// Here, as suggested in question input is given as 6.
printf("%lf\n", divideby3(6));
return 0;
}
Screenshot of the output: