Solved

repeat...until

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

756 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