[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Please Help

reepakmajhi.com@gmail.com

11/13/2008 3:19:00 PM

Solve this Question
Write a Program to find a number is even or odd?
8 Answers

Giff

11/13/2008 3:24:00 PM

0

reepakmajhi.com@gmail.com wrote:

> Solve this Question
> Write a Program to find a number is even or odd?

LOL, no shame at all!
Com'on, use your brain if you have one! How would you find out whether a
number is even or odd?

osmium

11/13/2008 3:29:00 PM

0

<reepakmajhi.com@gmail.com> wrote:

> Solve this Question
> Write a Program to find a number is even or odd?

The word you need is "modulo". Do something with it.


blargg.h4g

11/13/2008 4:25:00 PM

0

reepakmajhi.com@gmail.com wrote:

> Solve this Question
> Write a Program to find a number is even or odd?

Waste Google's time, not ours (it seems eager to help, BTW):

http://google.com/search?q=Write+a+Program+to+find+a+number+is+e...

red floyd

11/13/2008 5:36:00 PM

0

On Nov 13, 7:18 am, "reepakmajhi....@gmail.com"
<reepakmajhi....@gmail.com> wrote:
> Solve this Question
> Write a Program to find a number is even or odd?

Your answer can be found here: http://www.parashift.com/c++-faq-lite/how-to-post.ht...

ctrucza

11/13/2008 6:26:00 PM

0

On Nov 13, 5:18 pm, "reepakmajhi....@gmail.com"
<reepakmajhi....@gmail.com> wrote:
> Solve this Question
> Write a Program to find a number is even or odd?

how about this:

bool is_even(int n)
{
return ( (n == 0) || (n == 2) || (n == 4) || ... || (n ==
2*K) ); // for a carefully chosen value of K
}

Of course this will work correctly only for positive integers smaller
or equal than 2*K.
Extending it to work for negative numbers and other values of K is
fairly trivial.

Juha Nieminen

11/13/2008 7:39:00 PM

0

reepakmajhi.com@gmail.com wrote:
> Solve this Question
> Write a Program to find a number is even or odd?

Why don't you ask your teacher? That's what they are for.

Giff

11/14/2008 9:13:00 AM

0

ctrucza wrote:

> how about this:
>
> bool is_even(int n)
> {
> return ( (n == 0) || (n == 2) || (n == 4) || ... || (n ==
> 2*K) ); // for a carefully chosen value of K
> }

LOL

pandit

11/14/2008 9:19:00 AM

0

On Nov 13, 8:18 pm, "reepakmajhi....@gmail.com"
<reepakmajhi....@gmail.com> wrote:
> Solve this Question
> Write a Program to find a number is even or odd?

Use Your Mind and put the Logic in the Programming(C++).