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

  • Home
  • SEARCH
  • 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 8713079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:15:27+00:00 2026-06-13T05:15:27+00:00

The following code contains a logical error every time i run it and enter

  • 0

The following code contains a logical error
every time i run it and enter 1 or 0 the code
in the while loop is still executed.
can someone tell me why?

bool getmove()
{
    bool move;
    cout << "Would you like to make the first move?(1 for yes 0 for no)\n";
    cin >> move;
    while(move != 1 || move != 0 || !cin.good())
    {
        if(!cin.good())
        {
            cout << "ERROR please try again\n";
            cin.clear();
            cin.ignore(80,'\n');
            cin >> move;
        }
        else
        {
            cout << "Invalid input please try again\n";
            cin >> move;
        }
    }
    return move;
}
  • 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-13T05:15:28+00:00Added an answer on June 13, 2026 at 5:15 am

    Look at this line:

    while(move != 1 || move != 0 || !cin.good())
    

    It will always be the case that move != 1 || move != 0 (because it can’t be both).

    Furthermore, you’ll avoid some trouble by reading in something like a string and testing that, rather than relying on casting.

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

Sidebar

Related Questions

Assuming A.sql contains the following code, then second Select query won’t be executed due
3rd Code Sample contains the error - how to solve? In the following code
The following Microsoft example code contains the following: <Grid> ... <Border Name=Content ... >
I have the following code: $('.breadcrumb:contains(,)').hide(); It does as expected and hides the entire
My program contains the following code. pthread_t PThreadTable[32]; for (i=1; i<P; i++) // Checked
I'm using the following code which will generate a wav file which contains a
So I have the following code: echo '<li><a href="'.$Website.$Elements[2].'/'.$Row["povezava"].'" class="leftMenuArticlesInactive"></a><li>'; $Website contains: http://www.somesite.com/test/ $Elements[2]
Okay, so I created a JavaScript file called test.js which contains the following code:
I have a method that contains the following (Java) code: doSomeThings(); doSomeOtherThings(); doSomeThings() creates
I'm trying to compile some code which contains the following declaration, because I would

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.