Output of C Programs | Set 1
Predict the output of below programs.
Output:Above program goes in infinite loop because n is never zero when loop condition (n != 0) is checked.
Output is dependent on the compiler. For 32 bit compiler it would be fffffffe and for 16 bit it would be fffe.
Output: %s Geeks For Geeks Geeks For Geeks
Explanation: After pre-processing phase of compilation, printf statement will become.
printf("%s Geeks For Geeks ", "%s Geeks For Geeks ");
Now you can easily guess why output is %s Geeks For Geeks Geeks For Geeks.
Explanation: The do while loop checks condition after each iteration. So after continue statement, control transfers to the statement while(false). Since the condition is false ‘i’ is printed only once.
Now try below program.
Output: “Nice test for strings”
The above program works because string constants are stored in Data Section (not in Stack Section). So, when getString returns *str is not lost.