Solved && Operator Question

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
Take this code for example:
C++:
if ( variable1 = z && variable2 = x)
The && operator yields true if both expressions are true.

This question may be compiler and platform specific but...

If the first expression evaluates false does the processor even bother evaluating the second expression?
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,101
78,998
2,374
The second operand is checked only if the first operand evaluates to true (non zero) :)
 

dmo

Coder
Full Member
Nobleman
Nov 8, 2014
145
678
5
Take this code for example:
C++:
if ( variable1 = z && variable2 = x)
The && operator yields true if both expressions are true.

This question may be compiler and platform specific but...

If the first expression evaluates false does the processor even bother evaluating the second expression?
No.
*According to Bjarne Stroustrup. :smile:
 
Status
Not open for further replies.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods