Solved

repeat...until

Posted on 1998-11-18
5
208 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

717 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