cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
++ -- expressions
++ -- expressions
Mar 7, 2015 at 2:50pm UTC
VVS
(13)
int x = 5;
for (int j = 0; j < 10; j++) {
x++;
}
cout << x << endl;
a. 5 b. 9
c. 15 d. 16
I'm still confused on how to go about this....
i know the answer is 15 but can someone please explain step by step why?
thanks
Mar 7, 2015 at 3:03pm UTC
MiiNiPaa
(8886)
x++
is equals to
x = x + 1
Mar 7, 2015 at 4:58pm UTC
closed account (
E3h7X9L8
)
the for statement will increment x by 1 (x++) till j which is initialized as 0 will reach the value 10 , that means at the end of for loop x will have the value 15
Topic archived. No new replies allowed.