+ 6
Pls explain me this code..
#include <iostream> using namespace std; int main() { int c,j=0,n=0; for (c=1;c<=5;c++) { j=j++; } n=j+2; j=n; cout<<j; return 0; }
13 odpowiedzi
+ 2
I was confused. But then I realize it's j++ not ++j
+ 8
Everytime j=j++ gives the same value to j it means j=0 in every loop . After loop it is added by 2. Thus u get j=2. This is one quiz question.
+ 5
Good question. Now,here if we could use the keyword "static" to declare j, then may be, as per definition, it would update "j" everytime the for loop revolve.
+ 4
Thanku @mattias Ericsson now I understood
+ 3
no the output is 2
+ 3
that's why am confused
+ 3
the key is to study j=j++;
+ 3
no the answer is 2.. @vishnu ks
+ 3
K @vishnu
+ 3
yeah sure
+ 3
done Vishnu
+ 2
Ya @vignesh The output is 2. I got it.
0
so easy 2