Program to display the cube of the number upto given integer in C++
#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 << "Number is: " << i << " and its cube is: " << cube << endl;
}
}
Output
Input the number of terms: 5
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
Number is: 5 and its cube is: 125
