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 8586705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:22:32+00:00 2026-06-11T22:22:32+00:00

I have a quick question about a glitch in this coding. When I ran

  • 0

I have a quick question about a glitch in this coding.

When I ran this program and it entered this loop (by inputting 1 as the number), everything went smoothly, except that even though I entered ++generalcounter1; into the body of the loop, it doesn’t appear to be adding one to this variable every time the loop plays through. It never runs the message it is supposed to run when the variable == 10.

Please help me I’m very frustrated! Your advice is greatly appreciated!

Sorry if this was unclear, I’m new to this site as well as programming.

while (number == 1){
 int addend1;
 int addend2;
 int sum;
 int answer1;
 int generalcounter1 = 0;
 int reply1;

 ++generalcounter1;

 addend1 = 1 + rand() % 50;
 addend2 = 1 + rand() % 50;

 sum = (addend1 + addend2);

 cout << "\nWhat is " << addend1 << " plus " << addend2 << "? ";
 cin >> answer1;

 if (answer1 == sum){
     reply1 = winstatement(); 
 }          
 else{
     reply1 = losestatement();
 }

 if (generalcounter1 == 10){

     if (rightanswers >= 8){
        cout << "\nCongratulations, you are ready to go to the next level!\n" << endl;
     }
     else{
        cout << "\nPlease ask your teacher for extra help.\n" << endl;
     }  
  }   
}
  • 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-11T22:22:33+00:00Added an answer on June 11, 2026 at 10:22 pm

    You’re declaring a new generalcounter1 each iteration of the loop, incrementing it, and having it be destroyed at the end of the iteration. Move the declaration outside of the loop to have just the one incrementing each time, instead of a new one each time that just gets destroyed before it’s ever incremented twice.

    int generalcounter1 = 0;
    while (number == 1) { 
        //loop body
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quick question about saving data in symfony 2. I have this method (just
I have a quick question about jQuery selectors. Is doing this: $('.class_el_1, .class_el_2').hide(); The
I have a quick question about this PHP function here. What is the am
i have a quick question about objectify - this may be in the actual
Quick question about the most efficient was to handle this, I have a database
I have a quick question about HTML and CSS. I thought this would be
I have a quick question about while loop. I want to read ASCII char
I have a quick question about changing the file types PHP parses. This website
I just have a quick question about how you would typically approach this. I
I have quick question about text parsing, for example: INPUT=a b c d e

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.