# Answer to Question #20274 in C++ for sidra ahsaan

Question #20274

find even and odd numbers from n integers

Expert's answer

#include <stdio.h>

#include <iostream.h>

bool odd(int a){

if (a%2!=0) return true;

else return false;

}

void main()

{

int b[9999], n, i;

cout<<"how many integers do you want to set? ";

cin>>n;

cout<<"enter "<<n<<" integers: ";

for (i=0;i<n;i++) cin>>b[i];

cout<<"\neven:\n";

for (i=0;i<n;i++) if(!odd(b[i])) cout<<b[i]<<" ";

cout<<"\n";

cout<<"\nodd:\n";

for (i=0;i<n;i++) if(odd(b[i])) cout<<b[i]<<" ";

cout<<"\n";

}

#include <iostream.h>

bool odd(int a){

if (a%2!=0) return true;

else return false;

}

void main()

{

int b[9999], n, i;

cout<<"how many integers do you want to set? ";

cin>>n;

cout<<"enter "<<n<<" integers: ";

for (i=0;i<n;i++) cin>>b[i];

cout<<"\neven:\n";

for (i=0;i<n;i++) if(!odd(b[i])) cout<<b[i]<<" ";

cout<<"\n";

cout<<"\nodd:\n";

for (i=0;i<n;i++) if(odd(b[i])) cout<<b[i]<<" ";

cout<<"\n";

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment