Solved

repeat...until

Posted on 1998-11-18
5
202 Views
Last Modified: 2010-04-01
Is there a way to do a repeat - until statement?
ie..

repeat
      cout<<"is this bob?"<<endl;
      cin>>answer;
until
      answer='y'      


something like that....?
0
Comment
Question by:yaelie
  • 3
5 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 0 total points
Comment Utility

do {
     cout<<"is this bob?"<<endl;
     cin>>answer;
} while !(
     answer =='y'
     )

use ! (not) on the end condition
note == for comparison (otherwise you are assigning 'y' to answer)
0
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
Oops, last bracket should have ; after it

do {
          cout<<"is this bob?"<<endl;
          cin>>answer;
     } while !(
          answer =='y'
          ) ;
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
That is not exactly right.  The biggest problem is that it is formatted weirdly : - ).  the second problem is that "!" outside of the "()"  What you realy want is a != inside, like

do {
         cout<<"is this bob?"<<endl;
         cin>>answer;
} while (answer != 'y' ) ;
0
 
LVL 1

Author Comment

by:yaelie
Comment Utility
thank you...
0
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
Oops, formatting messed me up

Thanks for the correction nietod
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now