if (remainA == 0) cout<<"A = четное число "<<endl; else cout<<"A = Число нечетное"<<endl; Why remain here? What does it even do?
if (remainA == 0) cout<<"A = четное число "<<endl; else cout<<"A = Число нечетное"<<endl; Why remain here? What does it even do?
Apparently remain the remainder of the division. When divided by two, the even number has a remainder of 0. For odd 1
Why remain here? What does it even do?
In the code snippet you cited, the identifier remainA missing. :) The identifier remainA used remainA .
if (remainA == 0) ^^^^^^^^ cout<<"A = четное число "<<endl; else cout<<"A = Число нечетное"<<endl; Judging by the context, this variable stores the remainder of dividing a value in variable A by 2. If the value of this variable is even, then the remainder of dividing by 2 will be 0. That is, the remainA variable, the value of which is calculated in accordance with the logic of the following sentence,
remainA = A % 2; will be equal to 0.
Otherwise, if the variable A stores an odd number, then the remainder of dividing by 2 will be equal to 1, and the remainA variable will store this value of the remainder, that is, 1.
Depending on the value of the remainder of dividing by 2 values of the number stored in variable A stored in the remainA variable, a message is displayed on the console whether this stored number is even or odd.
Source: https://ru.stackoverflow.com/questions/574959/
All Articles
remainder(the remainder in English). But he did not have enough letters. - VladDcout << "A = " << (A % 2 ? "не" : "") << "четное число\n";or even like this:printf("A = %sчетное число\n", A & 1 ? "не" : "");much easier. - avp