# Answer to Question #49974 in C++ for vasanth

Question #49974

To write a program which inputs 25 integers in a 1-d array and copies all even integers in another array and all odd integers in third array.

Expert's answer

// The libraries

//To write a program which inputs 25 integers in a 1-d array

//and copies all even integers in another array and all odd integers in third array.

//

#include <iostream>

#include <cstdio>

#include <cmath>

#include <string>

#include <fstream>

using namespace std;

int main()

{

int arr[25];

const int N=25;int odd=0; int even=0;

cout<<"Enter 25 number please"<<endl;

for (int i=0;i<25;i++)

{

cout<<"["<<i+1<<"]"<<":";

cin>>arr[i];

if (arr[i]%2==0) even++;

if (arr[i]%2!=0) odd++;

}

cout<<"odd's number = "<<odd<<endl;

cout<<"even's number = "<<even<<endl;

int *oddarr = new int[odd];

int *evenarr = new int[even];

int oddfactor=0;

int evenfactor=0;

for (int i=0;i<25;i++)

{

if (arr[i]%2==0) {oddarr[oddfactor]=arr[i];oddfactor++;}

if (arr[i]%2!=0) {evenarr[evenfactor]=arr[i];evenfactor++;}

}

cout<<"Odd'd array"<<endl;

for(int i=0 ;i<oddfactor;i++){cout<<oddarr[i]<<endl;}

cout<<"Even's array"<<endl;

for(int i=0 ;i<evenfactor;i++){cout<<evenarr[i]<<endl;}

delete [] oddarr;

delete [] evenarr;

return 0;

}

//To write a program which inputs 25 integers in a 1-d array

//and copies all even integers in another array and all odd integers in third array.

//

#include <iostream>

#include <cstdio>

#include <cmath>

#include <string>

#include <fstream>

using namespace std;

int main()

{

int arr[25];

const int N=25;int odd=0; int even=0;

cout<<"Enter 25 number please"<<endl;

for (int i=0;i<25;i++)

{

cout<<"["<<i+1<<"]"<<":";

cin>>arr[i];

if (arr[i]%2==0) even++;

if (arr[i]%2!=0) odd++;

}

cout<<"odd's number = "<<odd<<endl;

cout<<"even's number = "<<even<<endl;

int *oddarr = new int[odd];

int *evenarr = new int[even];

int oddfactor=0;

int evenfactor=0;

for (int i=0;i<25;i++)

{

if (arr[i]%2==0) {oddarr[oddfactor]=arr[i];oddfactor++;}

if (arr[i]%2!=0) {evenarr[evenfactor]=arr[i];evenfactor++;}

}

cout<<"Odd'd array"<<endl;

for(int i=0 ;i<oddfactor;i++){cout<<oddarr[i]<<endl;}

cout<<"Even's array"<<endl;

for(int i=0 ;i<evenfactor;i++){cout<<evenarr[i]<<endl;}

delete [] oddarr;

delete [] evenarr;

return 0;

}

``

## Comments

Assignment Expert15.12.14, 20:59Dear salah, please use panel for submitting new questions

salah14.12.14, 11:34Write a program that can find the price of all cars in a gallery, the program must specify the total

of each car model and the year it was made for all models in the gallery assuming that there is only 3

cares models and at least 3 deferent years of made for each model.

For example if there is a Honda; and 3 deferent years made 2011, 2012, 2013; find the number of cars

made that year and the total sum price for each year.

## Leave a comment