C examples for Function:Function Return
Uses a function to calculate the cube of a number.
#include <stdio.h> long input, answer; long cube(long x){ long x_cubed;/* ww w. j a v a 2s . c om*/ x_cubed = x * x * x; return x_cubed; } int main( void ){ printf("Enter an integer value: "); scanf("%d", &input); answer = cube(input); printf("\nThe cube of %ld is %ld.\n", input, answer); return 0; }