64 573
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #24196 in C++ for Nourh

Question #24196
10. What is wrong with the following code?
for (int i = 0; i < 10; i++) {
int x = 4;
cout << i << endl;
}
cout << x << endl;
Expert's answer
your x value is a local variable, and is out ofsight, when you are trying to print it on screen after loop.
it is visible only inside loop!

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions