Solved

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

Posted on 2003-10-23
4
285 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

734 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