Output of C++ programs | Set 23
Question 1 What will be the output?
Answer: Compiler dependent. The subexpression x++ causes a side effect, it modifies x’s value, which leads to undefined behavior since i is also referenced elsewhere in the same expression. Please refer Sequence Points in C | Set 1 for details.
Question 2 How many times does the cout executes?
The continue statement will never let the cout statement get executed and thus never executed.
Question 3 What will be the output?
11 label x
This program is executed normally by entering for loop and in the first iteration, the control jumps to label x. We need to be careful while using goto statement because it may turn the program to infinite repetitions. For example, in the above program if we keep the for loop after the label then it will turn into infinite iterations.
Question 4 What will be the output?
Inside Switch case 1 Inside Switch case 2
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.