Codeblocks Help! (Cout)

After the code, I need to do this:

The numbers of numbers is
The average of the squares of the numbers is
The average the of the square roots of the numbers is
The sum of the numbers is
The sum of the square roots is

I have no idea how to do this. (In the output, it would say those messages along with the answers)

Could anyone post the code/or do this for em? Greatly appreciated, thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
  int Number, NSQ, NCUBE;
  float SQROOT;

  cout << "Number\t" << "NSQ\t" << "NCUBE\t" << "SQROOT\t" << endl;

  Number = 10;
  while (Number<=30) {
        NSQ = Number * Number;
        NCUBE = Number * Number * Number;
        SQROOT = sqrt (Number);
        cout << Number << "\t" << NSQ << "\t" << NCUBE << "\t" << SQROOT << "\t" <<endl;
        Number = Number + 2;
  }


    return 0;
}
Fist of all don't go float = sqrt (int). I would suggest switching nsq, number,ncube to a float. Point is avoid type conversion if you can.

As to how to output a variable see:

http://www.cplusplus.com/doc/tutorial/basic_io/
Topic archived. No new replies allowed.