Question: Please help me on how to add 2 to even integer and 3 to odd integer.This is my coding. #include #include using namespace std; int

Please help me on how to add 2 to even integer and 3 to odd integer.This is my coding.

#include
#include

using namespace std;

int main()
{
int Size, i, elm[10];
int even = 0, odd = 0;

cout << "Enter the Size of an Array :" << endl;
cin >> Size;

cout << "Enter the Array Elements" << endl;

for (i = 0; i < Size; i++)
{
cin >> (elm[i]);
}

for (i = 0; i < Size; i++)
{
if (elm[i] % 2 == 0)
{
even++;
}
else
{
odd++;
}
}

cout << "Total Even Numbers=" << even << endl;
cout << "Total Odd Numbers=" << odd << endl;

for (i = 0; i < Size; i++)
{
if (elm[i] % 2 == 0)
{
even=even+i;
}
else
{
odd=odd+i;
}
}
cout << "Total Even Numbers after add 10=" << even << endl;
cout << "Total Odd Numbers after add 5=" << odd << endl;
}

Step by Step Solution

3.40 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Your code has an issue You intend to add 2 to even integers and 3 to odd integers but currently you ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!