delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/11/16:03:55

Message-ID: <002901be3da3$a96848a0$c1d80ad0@default>
From: "Steve Axsom" <sssaxsom AT smithville DOT net>
To: <djgpp AT delorie DOT com>
Subject: Re: I can't seem to get this to work!
Date: Mon, 11 Jan 1999 15:47:52 -0500
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

-----Original Message-----
From: Jason Mullins <cyberj23 AT erols DOT com>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Monday, January 11, 1999 1:03 PM
Subject: I can't seem to get this to work!


>Hello -
>    Im new to programming.  I wondering why I can't get this code to
>count backwards form 6 to 0 and exit.  I will start at 6, and go down to
>negitives (becuase it's a "int").  I was told that it could be done in a
>while loop.  not a do while.  Any suggestions?
>
>
>Thanx in advance.
>
>Jason Mullins
>
>#include <stdio.h>
>
>int main()
>{
>int count;
>int cycle;
>    cycle = 0;
>    count = 6;
>    while (count <= 6, cycle = 6)
>    {
>        printf("The value of count is %d\n");
>        count = count--;
>        cycle = cycle++;
>     }
>     return 0;
>}
>
>
>

I made a few revisions to your code. I donno what you were using the int
cycle for, so I hope this is how you want-

#include <stdio.h>

int main()
{
int count=6;
    while (count>=0)
    {
        printf("The value of count is %i\n",count);
        count--;
     }
     return 0;
}

                                                            -Shane

- Raw text -


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