While structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sally999
    New Member
    • Nov 2007
    • 1

    #1

    While structure

    i dont even know where to start with this question..can anyone do it?

    Print the integers from 1 to 20 using a while structure and the counter variable x. Print only five integers per line. (Hint: Use the Modulo operator % to determine when every fifth integer has been printed)
  • dav3
    New Member
    • Nov 2006
    • 94

    #2
    well do you know how to declare a variable?

    that would be step 1.

    step 2 would be setting up your while loop.

    Code:
    while( variable < some value)
    {
       do something
       Increment counter
    }

    Comment

    • CodeTilYaDrop
      New Member
      • Aug 2007
      • 66

      #3
      Sally,

      Dave gave you a good start. If you have other problems after you write this code. You just come back. Everyone seems pretty helpful here.

      Comment

      • samido
        New Member
        • Oct 2007
        • 52

        #4
        try this as well:

        <Code removed>

        Comment

        • samido
          New Member
          • Oct 2007
          • 52

          #5
          Originally posted by Sally999
          i dont even know where to start with this question..can anyone do it?

          Print the integers from 1 to 20 using a while structure and the counter variable x. Print only five integers per line. (Hint: Use the Modulo operator % to determine when every fifth integer has been printed)
          OOPS:: try this...

          <Code removed>

          Comment

          • Ganon11
            Recognized Expert Specialist
            • Oct 2006
            • 3651

            #6
            Samido:

            Please refer to our posting guidelines for our policy about providing full code solutions to members. You can find our guidelines here.

            Comment

            Working...