8
Cube d'un nombre
- #include <stdio.h>
- int cube( int x ) {
- return x*x*x;
- }
- main() {
- int n;
- printf("? ");
- while ( scanf("%d", &n) == 1 ) {
- printf(" = %d\n", cube( n ));
- printf("? ");
- }
- }
$ gcc -o cube cube.c
$ ./cube
? 3
= 27
? -3
= -27
? 0
= 0
? q
Commentaires