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);
}

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

  1. #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;
    }

  2. #include
    #include
    Void main()
    {
    Int a,cube;
    Clrscr();
    Cout<>a;
    Cube=a*a*a=a3;
    Cout<<"the cube of number is"<<cube<<endl;
    Getch();
    }

  3. #include
    #include
    inline int cube(int a)
    {
    return(a*a*a*);
    }
    void main()
    {
    clrscr();
    int x,y;
    cout<>x;
    y=cube(x);
    cout<<"the cube of number="<<y;
    getch();
    }

  4. create c++ program to find the cube of a number using inline function. take data and display C++ program to find reverse of a number using class create function outside the class function should also be inline

Leave a Comment

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