C++ Program to find cube of number

This program takes in an integer a as a screen input from the user.
It then find cube of number and outputs it using the ‘cout’ command.

Table of Contents

PROGRAM:

#include <iostream.h>
#include <conio.h>
int cube(int x); //The prototype.

void main()
{
clrscr();
int a;
cout << "Enter an integer : ";
cin>>a;
cout << "The cube of " << a << " is : " << cube(a) << endl; //Call the function cube(a).
getch();
}
//Defining the function.
int cube(int x)
{
int y;
y=x*x*x;
return(y);
}

 

OUTPUT:

Enter an integer : 8

The cube of 8 is : 512

1 thought on “C++ Program to find cube of number”

  1. pls anyone kindly help me,pls! pls!!, write a c programme using the following for, why,and do-while statement on to computer the sum and product of even number between 2 and 24

    Reply

Leave a Comment