?
Solved

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

Posted on 2003-10-23
4
Medium Priority
?
287 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 375 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

764 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