D
D
DjTolib2021-06-27 17:03:29
C++ / C#
DjTolib, 2021-06-27 17:03:29

Why is the condition true?

#include<iostream>
int main()
{
   int a = 6;
   if(1 < a < 5)std::cout<<"IN";
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LoliDeveloper, 2021-06-27
@DjTolib

Because 1 < a= 1 (first operator)
AND = 1 (true) (second operator) That is, first the first operator is calculated , and what happened goes to the second operator . Write1 < 5
if(1 < a && a < 5)std::cout<<"IN";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question