Output of C Programs | Set 7
Predict the output of below programs
Output: Compiler error: Label “inside_foo” used but not defined.
Explanation: Scope of a label is within a function. We cannot goto a label from other function.
Preprocessor doesn’t give any error if we redefine a preprocessor directive. It may give warning though. Preprocessor takes the most recent value before use of and put it in place of a.
Now try following
g g g g g g g g e e k s f
Both s1 and s2 are initialized to str. In first loop str is being printed and s1 is being incremented, so first loop will print only g. In second loop s2 is incremented and s2 is printed so second loop will print “g e e k s f “
Following are different ways of indexing both array and string.
*(arr + i)
*(i + arr)
So all of them print same character.
Output: Compiler dependent. I got output as “1 4”
Output of the above program depends on compiler. sizeof(*p) gives size of character. If characters are stored as 1 byte then sizeof(*p) gives 1.
sizeof(p) gives the size of pointer variable. If pointer variables are stored as 4 bytes then it gives 4.