'C++ doesn't give me an output [closed]
I'm trying to loop through a 2d array and find the sum of some numbers but for some reason, I don't get any output from the compilier. Here is my code:
#include <iostream>
using namespace std;
int main()
{
int arr[3][3] = { {2,5,7},
{3,6,8},
{5,8,6} };
int oddSum = 0;
int evenSum = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
while (arr[i][j] != 2 && arr[i][j] % 2 == 0)
{
evenSum += arr[i][j];
}
while (arr[i][j] != 3 && arr[i][j] % 3 == 0)
{
oddSum += arr[i][j];
}
}
}
cout << "oddSum = " << oddSum << endl;
cout << "evenSum = " << evenSum << endl;
return 0;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
