Question #308835

Display the cube of the numbers up to a given intiger using any types of loop the suits to solve problem.



Expert's answer

#include <iostream>
using namespace std;

int main() {
    int n;

    cin >> n;
    for (int i=1; i<=n; i++) {
        int cube = i*i*i;
        cout << cube << endl;
    }

    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS