delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/23/09:58:32

Date: Thu, 23 Apr 98 18:45:48 PST
From: "altaf.aali" <altaf DOT aali AT cressoft-khi DOT com DOT pk>
Message-Id: <9803238933.AA893379938@cressoft.comsats.net.pk>
To: djgpp AT delorie DOT com, kenmel AT microtech DOT com DOT au
Subject: Re: simple program problem!!!

     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");
     

     


______________________________ Reply Separator _________________________________
Subject: simple program problem!!!
Author:  kenmel AT microtech DOT com DOT au at comsats
Date:    4/23/98 4:27 PM


I need help on a problem to do with a simple program for a course i am 
currently studying. I know most of the people reading this are far more 
advanced than the question, none the less I will still ask.
I need to write a program which obtains an integer value through the keyboard 
and the displays whether the integer is an even number or an odd number. The 
problem I have is - within the program how do I direct the program to 
distinguish whether the value is an odd or even number?
Any help would be greatly appreciated.
     
-----== Posted via Deja News, The Leader in Internet Discussion ==----- 
http://www.dejanews.com/   Now offering spam-free web-based newsreading

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019