how will i create a loop?

This is a discussion on how will i create a loop? within the C Programming forums, part of the General Programming Boards category; pls help me!!! I don't know how to create an output of all even numbers from 2-18 using a while ...

  1. #1
    ComSci newbie...ICS kid
    Join Date
    Jul 2006
    Location
    PHILIPPINES!!!
    Posts
    38

    how will i create a loop?

    pls help me!!! I don't know how to create an output of all even numbers from 2-18 using a while loop!!!!!!

  2. #2
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  3. #3
    ComSci newbie...ICS kid
    Join Date
    Jul 2006
    Location
    PHILIPPINES!!!
    Posts
    38
    i still can't get it.... where in the FAQ will I read it?

  4. #4
    ComSci newbie...ICS kid
    Join Date
    Jul 2006
    Location
    PHILIPPINES!!!
    Posts
    38
    will you please give me the commands for it?

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

    Wink

    can anyone pls give us the structure in looping "even" numbers so that we can easily understand how to loop.. we're just newbies in C programming so we need help.
    Anyone with a kind heart will be rewarded with BLESSINGS.

    ME and NESIR.

  6. #6
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Read fools.

    Quote Originally Posted by from the goddamned link that was provided to you
    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;
    }

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by nesir
    i still can't get it.... where in the FAQ will I read it?
    Make an attempt at searching for an answer.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    zomg do i look smarter cause i use !!!!!!!!!!!!

    That being said, there is plenty in the book that you are using to do this, you just have to take the time to read it. I have yet to come accross a basic programming language class that the book doesn't not cover loops and conditionals.

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Geez... another kid or teacher handing out the cboard link in programming 101 class, today. :/

    ...and from the time of year, I'd say these are the summer school flunkies, too. :/
    Sent from my iPadŽ

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Hey! I am a summer school kid! (though I haven't asked any homework questions here heh) I am getting the same assignments as these flunkies..

  11. #11
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Quote Originally Posted by Wraithan
    I am getting the same assignments as these flunkies..
    Well, why don't you indulge them with your solution. Wink, wink. Nudge, nudge. Say no more.
    Sent from my iPadŽ

  12. #12
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I would rather they failed and didn't end up in a workplace that I could end up in. If they don't want to put out the effort to read...

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,447
    > another kid or teacher handing out the cboard link in programming 101 class
    See, back in the old days, 101 was in decimal, and it implied at least a basic level of competence in something (I don't know what, maybe simple curiosity to actually try something then ask for help)

    Nowadays, 101 is in binary, and I have to wonder how some people manage to turn their PC's on.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by Wraithan
    I would rather they failed and didn't end up in a workplace that I could end up in. If they don't want to put out the effort to read...
    That's the point. Wink, wink, nudge, nudge.
    Come on, give them your solution.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #15
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    Code:
       while (int i = 2; i < 18); {
         printf("%s", i & 1? "odd" else "even", stdout);
       }
    Right?
    Last edited by whiteflags; 07-18-2006 at 01:26 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutiliplcation Program that uses a (do, while, and for loop)?
    By Debbie Bremer in forum C++ Programming
    Replies: 4
    Last Post: 10-11-2008, 06:04 PM
  2. Please help create a loop for embedded SQL
    By cjohnman in forum C Programming
    Replies: 4
    Last Post: 04-24-2008, 06:46 AM
  3. A somewhat bizzare problem!!! - WHILE LOOP
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 03-31-2006, 06:19 AM
  4. syntax question
    By cyph1e in forum C Programming
    Replies: 19
    Last Post: 03-30-2006, 11:59 PM
  5. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21