I guess I got this now :) but in Boolean expressions like (i*j%k==0 || j--<k++i got the first expression but I can't seem to grasp the second expression.
Would j-- be same as j=j-- meaning saving the value of j and then decrementing. Also in this Boolean expression since it's a if statement, this would not change the original value of j or k Correct?
Thank you! :D but since this is in a elseif(Boolean exoression) statement, would the value of j change from the original value. For instance. Let's say the value of j=2. After this Boolean exoression, would the value of j be changed to whatever that is?
Run this and it will explain to you exactly what is happening.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
int main()
{
int j = 10;
if(j-- == 9) // Checks to see if j is equivalent to 9. It isn't. Regardless it subtracts 1.
std::cout << "First expression: " << j; //Outputs 9
elseif(j-- == 9) // Checks to see if j is equivalent to 9. It is. Regardless it subtracts 1 again.
std::cout << "Second expression: " << j; //Outputs 8.
while(true)
{
}
return 0;
}
It checks to see if j is equivalent to whatever you're comparing it to before it does the operations on j.
I did run it and in fCt was playing around it with on visual studio. I do get it now but k=j-- I don't understand how the value of 3 is being stored for j. Can you explain to me how this expression is working step by step please. The original value of k and j are 4.