84 419
Assignments Done
98,8%
Successfully Done
In March 2020

Answer to Question #43991 in C++ for Celina

Question #43991
/* PROGRAMMING ASSIGNMENT 1: Input: Enter five real numbers. Output: Find the sum, product and relationship of each pair of numbers e.g: input: 1,2,3,4,5 output: The sum are:3,4,5,6,5,6,7,7,8,9 The products are:2,3,4,5,6,8,10,12,15,20 The relationship are: 1 &lt; 2 1 &lt; 3 1 &lt; 4 1 &lt; 5 2 &lt; 3 2 &lt; 4 2 &lt; 5 3 &lt; 4 3 &lt; 5 4 &lt; 5
1
2014-07-07T15:31:39-0400
#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;
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 order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!