quick do while loop question

This is a discussion on quick do while loop question within the C Programming forums, part of the General Programming Boards category; If i have an unknown constant that the user must input in the do portion of the do-while loop, do ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    15

    quick do while loop question

    If i have an unknown constant that the user must input in the do portion of the do-while loop, do i have to define the constant in the DO statement like


    [/code]
    do {
    int c;

    c = getchar()


    }

    [code]

    or can the information come before the DO

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    If you need to use a variable outside of a statement block, you need to declare it outside of the statement block.
    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.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick question about types...
    By Elysia in forum C++ Programming
    Replies: 32
    Last Post: 12-07-2008, 04:39 AM
  2. Help Please, Beginner Question, rewrite loop
    By office888 in forum C Programming
    Replies: 4
    Last Post: 12-11-2006, 09:07 AM
  3. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 08:23 AM
  4. simple for loop function question
    By felicityxiv in forum C Programming
    Replies: 7
    Last Post: 05-06-2006, 11:43 PM
  5. Please don't laugh...SIMPLE loop question!
    By the_lumin8or in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2006, 12:08 PM

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