このコーディングの不具合について簡単な質問があります。
このプログラムを実行して(数値として1を入力して)このループに入ったとき++generalcounter1;
、ループの本体に入ったとしても、毎回この変数に1を追加しているようには見えないことを除いて、すべてがスムーズに進みました。ループが再生されます。変数==10の場合に実行されるはずのメッセージは実行されません。
とてもイライラしているので助けてください!あなたのアドバイスは大歓迎です!
これが不明な場合は申し訳ありませんが、私はこのサイトとプログラミングを初めて使用します。
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;
}
}
}