0

How to write a program that will find the smallest, the largest, and sum of squares values in a collection of N numbers? (using loops)

Edited by alan91

3
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by Lucaci Andrew
0

We will not do your homework for you. Have you tried? What code do you have so far? Do you have a specific problem? You have to show some efforts before we can help.

0

As mike_2000_17 said: we can help you only if you show us some code, or some attempts of doing the actual homework.
In your program you'll need a container in which you'll store the integers.
You will need after that another 3 distinct integers, one which will hold the smallest element from the container, one which will hold the greates ellement, and on that will hold the sum of the squares.

(using loops)

It would be extreamly hard, if not impossible, without them.

For the square part, I suggest looking into this:
Cmath
CPow

Here's a quick program, to get you started, of how to compute the square of an integer:

#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int a=4;
    cout<<pow(a, 2);
    return (0);
}

Edited by Lucaci Andrew

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.