Cube function
Posted by JanWan
Last Updated: March 05, 2012
  571

#include <stdio.h>

long cube(long x);

long input, answer;

main()
{
printf("Enter an integer value: ");
scanf("%d", &input);
answer = cube(input);
/* Note: %ld is the conversion specifier for */
/* a long integer */
printf("\nThe cube of %1d is %1d.\n", input, answer);

return 0;
}

/* Function: cube() - calculate the cube value of a variable */
long cube(long x)
{
long x_cubed;
x_cubed = x * x * x;
return x_cubed;
}
   
  
 
 
   

 
 
kool! Great for beginners!