Program to enter an integer and output the cube of that integer

Join Our Official Freshers Jobs Telegram Channel
#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);
}

 

This program takes in an integer a as a screen input from the user.
It then determines the integer’s cube and outputs it using the ‘cout’ command.
INPUT :
8

OUTPUT :
The cube of 8 is : 512