From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: simple program problem!!! Date: Fri, 24 Apr 1998 07:52:56 -0400 Organization: Cornell University (http://www.cornell.edu/) Lines: 22 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <35407D18.79AF0558@cornell.edu> References: <9803238933 DOT AA893379938 AT cressoft DOT comsats DOT net DOT pk> NNTP-Posting-Host: cu-dialup-2228.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk altaf.aali wrote: > > simply add this code snippet.... > // I assume you have declared the input value as int value > int remainder; > > remainder = value%2; // take the mod of the number with 2 > if (!remainder) // if there is no remainder > printf ("Even number"); > else > printf ("Odd number"); an odd integer has bit 0 set. simply test for that. (no code, since i don't like doing others' homeworks.) -- ---------------------------------------------------------------------- A. Sinan Unur Department of Policy Analysis and Management, College of Human Ecology, Cornell University, Ithaca, NY 14853, USA mailto:sinan DOT unur AT cornell DOT edu http://www.people.cornell.edu/pages/asu1/