You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
356 B
C
24 lines
356 B
C
//Demonstrates a simple function in C code
|
|
#include <stdio.h>
|
|
|
|
long cube(long x);
|
|
|
|
long input, answer;
|
|
|
|
int main(void){
|
|
printf("Enter an integer value: ");
|
|
scanf("%ld", &input);
|
|
answer = cube(input);
|
|
|
|
printf("\nThe cube of %ld is %ld.\n", input, answer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
long cube(long x){
|
|
long x_cubed;
|
|
|
|
x_cubed = x * x * x;
|
|
return x_cubed;
|
|
} |