how to write a program to read a number n

closed account (1hfjLyTq)
and print n2,n3.
You wont get any answers when you post ten questions like the one above. Descripe what you want, what the problems is , and post the code you already have. Then people may help you.
Last edited on
The most simple example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
        int n;

        cout << "Give me number: ";
        cin >> n;

        cout << "n^2 = " << pow(n, 2) << endl;
        cout << "n^3 = " << pow(n, 3) << endl;

        return 0;
}


At a pinch use n * n instead function pow().
@Karql: Don't give out code, people like the OP will just steal it and not learn anything
@firedraco: I know, but I saw all @ankitsikka1992 topics like this after send post.
Topic archived. No new replies allowed.