GATE | Quiz for Sudo GATE 2021 | Question 19
Consider the C program given below.
Which of the following string(s) is/are part of output of above C program ?
Note – This question is multiple select questions (MSQ).
Answer: (B) (C)
Base Address s1=1000
Base Address s2=2000
s1 pointer array contains the base addresses of the strings.
s2=1000 double pointer array contains the addresses of the pointer array s1.
s3=2000 triple pointer contains the base address of the address array s2.
s3++ means increment to next index value by 4 which means 2000 + 4 =2004
In first print statement
**++s3 again s3 incremented to 2008.
At 2008 (s2) contains to s1+3 and (s1+3) points to “Sanghai”.
In second print statement
s3-s2 = 2008 - 2000 / 4(size of the data type) = 2 *s3 - s1= 1012-1000/4 = 3
So, output of given C program is : I love to visit Sanghai 2-3 times every year.
Hence, ‘Sanghai’ and ‘2-3’ are strings part of the output.
Quiz of this Question