Question #1572

The program will ask for a number. Then will display the odd numbers on that number. Then on the next line will show the even numbers from the number we have input.

Then add up all even numbers... and then multiply all the odd numbers

Then add up all even numbers... and then multiply all the odd numbers

Expert's answer

`#include <cmath>`

#include <iostream>

using namespace std;

int main(int argc, _TCHAR* argv[]){

int evendata[100];

int odddata[100];

int a, b, c;

int multiplyodd=1;

int sumeven=0;

b=0;

c=0;

do

{

cout << "Please enter a positive integer (negative integer to stop):"<< ' ';

cin>> a;

if (a>0){

if (a%2 == 0 )

{

c++;

evendata[c]=a;

}

else{

b++;

odddata[b]=a;

}

}

}

while (a>=0);

cout << "You have entered" << ' '<< b << ' ' <<"odd numbers: " ;

for(int i=1;i<=b;i++){

multiplyodd*=odddata[i];

cout<<<" ";

}

cout << endl<< "And" << ' ' << c << ' ' <<"even numbers: ";

for(int i=1;i<=c;i++){

sumeven+=evendata[i];

cout<<<" ";

}

cout<<<"The sum of even numbers is "<<<<"The multiply of odd numbers is "<<< endl<< "Press any key to exit";

getch();

return 0;

}

Learn more about our help with Assignments: C++

## Comments

## Leave a comment