Increement and decrement | Sololearn: Learn to code for FREE!

0

Increement and decrement

I dont understand this int b=6, (b++==7 ) what is output

c++

1/3/2018 9:27:05 AM

Aviastix

2 Answers

New Answer

+17

Your question isn't clear... b++ is post increment i.e increasing value after checking the condition... thus 6==7 is False but aftee this the value of b increases by 1 thus b=7 Use this for reference https://www.sololearn.com/Discuss/407846/?ref=app

+9

int b=6; cout<<(b++==7); //outputs 0 b++ increments b on next line while ++b increments on the same line.. for eg:- int b=6; cout<<(++b==7); // this will output 1 //as b will be incremented 1st & then the operation is done.. For more u can check below post.. https://www.sololearn.com/discuss/489143/?ref=app