# Answer to Question #44013 in C++ for IG1120

Question #44013

you let user to input 5 real numbers. the computer must output the following:

the sum, product, and relation of each pair of numbers.

the sum, product, and relation of each pair of numbers.

Expert's answer

`#include <iostream>`

void sum(int* array, int size ) {

std::cout << "The sum are: ";

for ( int j = 0; j < size; j++) {

for ( int i = j+1; i < size; i++ ) {

std::cout << array[i] + array[j] << " ";

}

}

std::cout << std::endl;

}

void product( int* array, int size ) {

std::cout << "The product are: ";

for ( int j = 0; j < size; j++) {

for ( int i = j+1; i < size; i++ ) {

std::cout << array[i] * array[j] << " ";

}

}

std::cout << std::endl;

}

void readNumbers( int* array, int size ) {

for ( int i = 0; i < size; i++ ) {

std::cin >> array[i];

}

}

void relations ( int* array, int size ) {

for ( int j = 0; j < size; j++) {

for ( int i = j+1; i < size; i++ ) {

if (array[j] > array[i]) {

std::cout << array[j] << " > " << array[i] << std::endl;

} else {

std::cout << array[j] << " < " << array[i] << std::endl;

}

}

}

}

int main() {

const int SIZE = 5;

int *array = new int[5];

std::cout << "Enter 5 real numbers." << std::endl;

readNumbers(array, SIZE);

for ( int i = 0; i < SIZE; i++ ) {

std::cout << array[i] << " ";

}

sum(array, SIZE);

product(array, SIZE);

relations(array, SIZE);

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment