Write a function that calculates the cube of any number passed as paramater.
Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
double cube(double nb)
{
return (nb * nb * nb);
}
void main()
{
int nb;
printf("Enter a number: ");
scanf("%d", &nb);
printf("Cube of %d is %.2lf\n", nb, cube(nb));
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Multiplication of a matrix by a number using an iterative function