# Program to display the cube of the number upto given integer in C++

### Program in C++ to display the cube of the number up to given an integer

Given: User will input number of terms and we have to print its cube till the given number of terms.

Example:

Input the number of terms : 4

Number is: 1 and its cube is: 1

Number is: 2 and its cube is: 8

Number is: 3 and its cube is: 27

Number is: 4 and its cube is: 64

### # Algorithm

1. Take the number of terms as input from the user.
2. Start loop from i =1 to i<= n
3. Cube= i*i*i

4. Print number and its cube as result.

Code:

// C++ program to display the cube of the numbers upto a given integer
#include <iostream>
using namespace std;
int main()
{
int i, n, cube;
cout << "Input the number of terms : ";
cin >> n;
for (i = 1; i <= n; i++){
cube = i * i * i;
cout &lt;&lt; "Number is: " &lt;&lt; i &lt;&lt; " and its cube is: " &lt;&lt; cube &lt;&lt; endl;

}
}