0
how does this code works ?
I got this code: #include <iostream> using namespace std; int main() { int x,y=7; x=y=8; y=--x%y; cout<<y; return 8; } so in the third command first it decreases x so x now is 7 then assigns it to y so y is 7 then what next ?
5 Antworten
+ 2
--x%y will first decrease the value of x from 8 to 7 then get the % modulus (remainder) of x/y. 8 goes into 7, 0 times leaving a remainder of 7. So 7 is returned and y = 7.
+ 2
x and y both are equals value 8
the x is then decrease when
--x%y so the value of x is 7
7%8 gives the remainer of 7.
0
you've re-assigned x and y to the value 8...
the x is then pre-decremented so it's now 7.....so..
7%8 gives the remainer of 7.
0
thanks guys....my biggest Problem was if after the increment it assigns or does the remainder..now clear
0
thanks guys....my biggest Problem was if after the increment it assigns or does the remainder..now clear