Kat H.

# Squares Adder. Write a program that reads in a number (integer) indicating how many values you are to read.

Write a program that reads in a number (integer) indicating how many values you are to read. Then read in that many more numbers (all integers) and output the sum of their squares.

Input of 4 1 2 3 4 would mean "Read in 4 numbers" - the 1 2 3 and 4. Read each one in and add its square to the total. 1+4+9+16 would mean an output of 30

Hint: Steps to a solution:

1. First read in the first input (how many more numbers there are and count from 1 to that value. The first test should count to 4, the second test count to 2, the third test count to 6.
2. Then instead of just counting - try to read in that many inputs and print them back out. Basically print all of the inputs except the first. (First test should print 1 2 3 4, second 5 10, third 2 4 8 16 32 64
3. Then print each number squared
4. Now you can worry about summing the squares

Code:

#include <iostream>

using namespace std;

int main()

{

//YOUR_CODE

}

## 2 Answers By Expert Tutors

By: Tutor
4.7 (31)

Math and computer tutor/teacher Tutor
5 (7)