Solved

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

Posted on 2003-10-23
4
284 Views
Last Modified: 2010-04-01
need simple code to print pair numbers and odd numbers from a previous inserted numbers
0
Comment
Question by:paStiSSet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9607505
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
 
LVL 1

Author Comment

by:paStiSSet
ID: 9607551
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
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 9607591
#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
 
LVL 9

Expert Comment

by:tinchos
ID: 9607772
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VS2015 compilation and missing DLLs 9 181
Socket Programming (Unix) 8 153
passing data from one form to another form in c++ 27 88
c++, dynamic object by json 1 60
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question