帮助如果-否则

帮助如果-否则

问题描述:

任何建议,如果我指出否则将不符合该声明,但没有预期结果的原因.

在此先感谢您的帮助.

这是一个较大的带有类ect的数学抽认卡程序的一部分...我正在使用DEV C ++,并在else语句处的编译过程中设置了一个错误以进行加法,减法ect ...我得到的信息应为之前的主要表达式''其他''



无效Flashcard :: AdditionQuestion()
{
number1 = getRandom_Number(); //获取随机数
number2 = getRandom_Number(); //获取随机数

sum =数字1 +数字2;
cout<<数字1<< "+" <<数字2<< " = \ n;
setUserAnswer();

if(getUserAnswer()== sum);
{
AdditionCounterCorrect ++;
cout<< " \ n";
CorrectAnswer();

}
其他

{
AdditionCounterIncorrect ++;
//cout<< 对不起,很抱歉";
cout<<正确的答案是<<总和<< ".\ n";
WrongAnswer();
}

返回;
}

Any suggestions why this statement won''t complie if I remark out the else it will complie but without expected results.

Thanks in advance for any help..

This is part of a larger math flashcard program with classes ect... I am using DEV C++ and set an error during compile at the else statements for addition, subtractiom ect... the info I get is expected primary-expression before ''else''



void Flashcard::AdditionQuestion()
{
number1 = getRandom_Number(); // Gets random number
number2 = getRandom_Number(); // Gets random number

sum = number1 + number2;
cout << number1 << "+" << number2 << " = \n";
setUserAnswer();

if ( getUserAnswer() == sum );
{
AdditionCounterCorrect++;
cout << "\n";
CorrectAnswer();

}
else

{
AdditionCounterIncorrect++;
// cout << "Sorry that is WRONG";
cout << "The correct answer is "<< sum << ".\n";
WrongAnswer();
}

return;
}

删除if(getUserAnswer() == sum);末尾的分号可能会有所帮助:)
下次请先检查一下:)
欢呼声,
AR
Removing the semicolon at the end of if(getUserAnswer() == sum); might help :)
Next time check that at first :)
cheers,
AR