Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Solution are uploaded ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Engineering Mathematics

Authors: Erwin Kreyszig

10th edition

470458364, 470458365, 978-0470458365

More Books

Students also viewed these Programming questions

Question

What problems are associated with tracking historical costs?

Answered: 1 week ago

Question

discuss how hotels communicate performance

Answered: 1 week ago