if (remainA == 0) cout<<"A = четное число "<<endl; else cout<<"A = Число нечетное"<<endl; 

Why remain here? What does it even do?

Closed due to the fact that off-topic participants Denis , D-side , pavel , Kromster , HamSter Oct 8 '16 at 4:53 .

  • Most likely, this question does not correspond to the subject of Stack Overflow in Russian, according to the rules described in the certificate .
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    This question should be closed, because this question is beneficial only to the author and is useless to others. - Denis
  • 3
    Apparently, the author of the code wanted to write a remainder (the remainder in English). But he did not have enough letters. - VladD
  • I also do not understand why so many letters? See, it’s like this: cout << "A = " << (A % 2 ? "не" : "") << "четное число\n"; or even like this: printf("A = %sчетное число\n", A & 1 ? "не" : ""); much easier. - avp
  • Bukov him enough. But there is no autocomplete in the notebook, and the hand will quickly get tired of printing everywhere remainder_of_A, I had to cut it. - Sergey

2 answers 2

Apparently remain the remainder of the division. When divided by two, the even number has a remainder of 0. For odd 1

  • one
    Correct - "at the odd 1" - Denis
  • @Denis, thank you, corrected - Artem Y

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.