ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/30/01:51:30

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Loops
Date: Sat, 30 Nov 1996 01:04:34 -0800
Organization: Three pounds of chaos and a pinch of salt
Lines: 34
Message-ID: <329FF8A2.7EC7@cs.com>
References: <01bbde81$ba443400$0116a5ce AT pentium-133>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp102.cs.com
Mime-Version: 1.0
To: Mike McLean <libolt AT primenet DOT com>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mike McLean wrote:
> 
> sorry to bother again, but how do I do IF Then and while do loops?
> 
> any help is appreciated

if ( condition )		while ( condition )
    statement(s);		    statement(s);
else
    statement(s);

If more than one statement, you need to enclose them in braces, eg.:

int x = 4, y = 10;

while ( x < y )
{
    if ( y - x > 4 )
        x += 2;
    else
        x += 1;

    printf( "x = %d, y = %d\n", x, y );
}

PLEASE find a good C book or class and curl up with it.  This newsgroup
is not here to answer basic questions about the language.

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |        fighteer AT cs DOT com          |
| Proud owner of what might one   |   http://www.cs.com/fighteer    |
| day be a spectacular MUD...     | Plan: To make Bill Gates suffer |
---------------------------------------------------------------------

- Raw text -


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