Member Avatar for alan91

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)

Recommended Answers

All 2 Replies

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.

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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.