What will be the output of the following segment of the prog
What will be the output of the following segment of the program?
int total =50;
for ( i = 1; i <= 10; i += 2)
cout << i << endl;
My answer is:
1 3 5 7 9
Is the int total=50 there to trick me? Because its initializing the variable total when the display isnt even displaying total variable, its displaying i instead.
Solution
ther are 2 cases in this progarm...
case 1: I think the code in incomplete ..
solution : If you sure that you have copied full code .. then no problem..
case 2: why total is used?
solution.: total is not a part of the code..
then what this code prints:? it prints only 1 3 5 7 9
total value is just decalred but not used.
