Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:12:18+00:00 2026-06-14T07:12:18+00:00

I am a beginner in C++ and I was doing a do/while loop exercise

  • 0

I am a beginner in C++ and I was doing a do/while loop exercise and I am having trouble with it recognising the condition let alone it not looping properly. Can you guys give me a good foundation on how a simple problem like this is solved? I want to try and use a string to fulfill the condition of the do/while loop.

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main ()
{
    double mean = 0;
    string continuer;
    do
    {
        cout << "Do you want to proceed?" << endl;
        getline (cin, continuer);
        cout << "something" << endl;
        cin >> mean;
    }
    while (continuer == "Y" || continuer == "y");

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:12:19+00:00Added an answer on June 14, 2026 at 7:12 am

    What I gather from your question and comment, you want to iterate through the loop at user’s will.

    You just want a char variable for that, like this.

    string input ;
    int number = 0 ;
    
    do
    {
      cout << "Please enter a number" << endl ;
      cin >> number ;
      cout << "If you want to continue, Press Y" << endl ;
      cin >> input ;
    
    } while (input == "Y" || input == "y") ;
    

    This do-while loop will execute at least one time, because the condition gets checked at the end of the loop execution. So even if the user does not press Y when asked the first time, this loop would have been executed once. After that, it will go on as long as the condition is fulfilled.

    Learn more about the do-while loop here.

    http://www.cplusplus.com/doc/tutorial/control/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner in Java and am doing an exercise from a book.
I am a beginner in java .So please let me know how can i
I'm just a beginner :P. I'm doing a tutorial about while loops on Codeacademy
I'm just a beginner at c++ so I might be doing something wrong but
I'm a beginner in Flex so there must be more elegant way of doing
Beginner here trying to get a pipeline working in bash. If somebody can see
First of all, I'm a beginner on shell-script. This code I've done is not
HI. I am doing a web project... I am still a beginner with visual
Let me preface this post with a single caution. I am a total beginner
I'm a beginner and doing my homework. My button is filling up the whole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.