C Program to find cube of a number

Category: C ProgramTags: cprogram function

C Program to find cube of a number

C Program to find cube of a number using function

#include <stdio.h>

float cube(float num);

void main()
{
    float num, result;
    printf("Enter number: ");
    scanf("%f", &num);

    result = cube(num);
    printf("Cube of %0.2f is %0.2f", num, result);
}

float cube(float num)
{
    return num * num * num;
}

Output

Output

Enter number: 2
Cube of 2 is 8