+ 1
Is it possible to be done with array?
You traverse through the array elements. Print the every sum of two elements of array. Example: int array[] = {1, 2, 3}; Output:3, 4, 5
5 Answers
+ 2
Yes it's possible
Do you want it like this na
1 + 2 = 3
1 + 3 = 4
2 + 3 = 5
... ...
+ 2
Yes it's possible using nested loop
https://code.sololearn.com/c6VZ72rs3W19/?ref=app
0
int sum = 0;
for (int i = 0; i < sizeof (array) / sizeof(array[0]); i++)
{
for (int j = i + 1; j < sizeof (array) / sizeof(array[0]); j++)
{
sum += array[i] + array[j];
}
}
0
I highly recommend you to solve it for 3,4,5... Elements