?
Solved

repeat...until

Posted on 1998-11-18
5
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 0 total points
ID: 1178139

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
ID: 1178140
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
ID: 1178141
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
ID: 1178142
thank you...
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1178143
Oops, formatting messed me up

Thanks for the correction nietod
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

650 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