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

Question #20274
find even and odd numbers from n integers
1
Expert's answer
2012-12-13T10:00:41-0500
#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";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS