C++ Program to find cube of a number using function

C++ Program to find cube of a number using function

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();                                                //to clear screen
float cube(float);                                  //function prototype
float a,cu;
cout<<“Enter any number:”;
cin>>a;
cu=cube(a);                                         //function calling
cout<<“nCube of “<<a<<” is “<<cu;
getch();
}

float cube(float a)
{
float cu;
cu=a*a*a;
return(cu);
}

4 thoughts on “C++ Program to find cube of a number using function

  1. shashank jha

    #include
    #include
    int i=0;
    int Cube(int n){
    if (i==3){
    return 1;
    }
    else {
    i++;
    return n*Cube(n);
    }
    }
    int main()
    { int n,cube;
    printf(“Please enter the number!\n”);
    scanf(“%d”,&n);
    cube=Cube(n);
    printf(“\nThe cube if %d is %d”,n,cube);
    return 0;
    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *