Thread: Need help to make a simple program using while or do-while loop

  1. #1
    Registered User
    Join Date
    Nov 2013
    Posts
    2

    Unhappy Need help to make a simple program using while or do-while loop

    hi, please anyone help me making a simple program thats given in my assignment
    "Write a program in three different methods using while or do-while loop to display a message by entering any number b/w 1-50 "

    i have done with 2 methods but stuck on 3rd
    now key point is only when 25 is entered the message "OK" is displayed other wise "invalid try again " is displayed and the end user is prompt to enter a digit again

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Sounds like you didn't do it right. Hard to say what you did wrong without knowing what you did.

  3. #3
    Registered User
    Join Date
    Nov 2013
    Posts
    2
    Quote Originally Posted by tabstop View Post
    Sounds like you didn't do it right. Hard to say what you did wrong without knowing what you did.
    oh no you got it wrong actually i didn't understand now how to do the same program in 3rd different method using loop give me some idea ... nd im on beginners level not so much aware of language :'(

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by momna View Post
    oh no you got it wrong actually i didn't understand now how to do the same program in 3rd different method using loop give me some idea ... nd im on beginners level not so much aware of language :'(
    I had taken "only when 25 is entered the message "OK" is displayed other wise "invalid try again " is displayed" to be what your program was doing. If that isn't what your program is doing, then why is that sentence there?

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    If you have been taught the "break" keyword, using it could be an easy third way.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple program, stopping invalid character infinite loop
    By samwillc in forum C++ Programming
    Replies: 16
    Last Post: 01-06-2013, 03:18 PM
  2. Make a simple C Program
    By jhunluis in forum C Programming
    Replies: 22
    Last Post: 09-04-2009, 03:50 AM
  3. Very simple loop program for payroll
    By alexpos in forum C Programming
    Replies: 17
    Last Post: 10-19-2005, 06:19 PM
  4. Replies: 4
    Last Post: 07-05-2004, 07:41 PM
  5. Replies: 2
    Last Post: 03-25-2002, 05:49 AM