home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day05
/
cube.c
next >
Wrap
C/C++ Source or Header
|
2002-04-14
|
532b
|
29 lines
/* Demonstrates a simple function */
#include <stdio.h>
long cube(long x);
long input, answer;
int main( void )
{
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 %ld is %ld.\n", input, answer);
return 0;
}
/* Function: cube() - Calculates the cubed value of a variable */
long cube(long x)
{
long x_cubed;
x_cubed = x * x * x;
return x_cubed;
}