GATE | Quiz for Sudo GATE 2021 | Question 18
Consider the following C program :
Which of the string(s) will be in the final output of the above C program ?
Note – This question is multiple select questions (MSQ).
Answer: (A) (C) (D)
Explanation: Here structure is the data type contains integer type and string. Base address of strings,
eclasses=1000 geeks=2000 data=3000 structure=4000 students=5000
p contains the base address of the str data type.
means jump to index 0 to index 1 <200,2000>in array str.
First print statement, p->c points to the base address of the string and print statement print till null found in the string.
Second print statement
p– means back to index 0,
++p -> c means traverse the string one byte and print the remaining string
Third print statement
p.i prints the integer stored at 1 index.
Fourth print statement
p=p+4 means go to index 4
p->c print string stored at index 4
Therefore, options (A), (C), and (D) are correct.
Quiz of this Question
Please comment below if you find anything wrong in the above post