• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

need simple code to print pair numbers and odd numbers from a previous inserted numbers

need simple code to print pair numbers and odd numbers from a previous inserted numbers
0
paStiSSet
Asked:
paStiSSet
  • 2
1 Solution
 
jkrCommented:
int numbers [] = { ... };

for ( int i = 0; i < sizeof ( numbers); ++i) {

  if ( numbers [ i] % 2) {

      printf ( "%d is odd\n", numbers [ i]);

  } else {

      printf ( "%d is even\n", numbers [ i]);
  }
}
0
 
paStiSSetAuthor Commented:
ok is right, so i'm not looking for a code wich has the numbers inserted in the code, the numbers will be inserted by the user who runs the program :)
0
 
jkrCommented:
#include <iostream>
using namspace std;

int n;

 cout << "Enter a number: ";
 cin >> n;

 if ( n % 2) {

     cout << n " is odd\n" << endl;

 } else {

     cout << n " is even\n" << endl;
 }

:o)
0
 
tinchosCommented:
Hey paStiSSet

I don't believe that there is any reason to post the same question in 2 different areas

http://oldlook.experts-exchange.com/Programming/Programming_Languages/C/Q_20775992.html
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now