Thread: About using "while" statement in a loop.

  1. #1
    Registered User
    Join Date
    Jul 2006
    Location
    somewhere in Asia
    Posts
    5

    Unhappy About using "while" statement in a loop.

    Pls i need help in how to output even numbers from 2- 18 using the while statement(loop)
    This is our assignment, i've researched about "while" but i still could'nt get the structure.
    pls anyone help me!!!

    I'm using "C"
    Last edited by tatsume05; 07-17-2006 at 09:44 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You can fill in the rest, but here's the basic structure. Don't want to do everything for you after all
    Code:
    #include <stdio.h>
    
    int main(void)
    {
      // Declare and initialize num variable here
    
      while(num <= 18)
      {
        // Print the number
        // Add 2 to the number
      }
    
      return 0;
    }
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Location
    somewhere in Asia
    Posts
    5
    gee thanks! 4 the structure! I'm still trying to learn C. we've just started programming today so it's my first time. BASIC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-01-2008, 10:09 AM
  2. Switch statement = infinite loop
    By Lucid003 in forum C++ Programming
    Replies: 10
    Last Post: 10-10-2005, 12:46 AM
  3. Replies: 26
    Last Post: 06-15-2005, 02:38 PM
  4. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 04:13 AM
  5. explain this loop statement?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-05-2002, 02:46 AM