Question about the output from a code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Question about the output from a code

Why the outcome of this code is not 4? Am I missing something? #include <iostream> using namespace std; int f(int k){ k++; return k; } int main() { int k{2}; k++; /*k=3*/ f(k); /*inside the function, it has k++,so k should be 4(?!)*/ cout<<k; return 0; }

21st Nov 2019, 4:14 PM
汝風留名
汝風留名 - avatar
1 Answer
+ 1
oh I missed that. Thx xD
21st Nov 2019, 4:28 PM
汝風留名
汝風留名 - avatar