GATE | GATE-CS-2017 (Set 2) | Question 53

Consider the following program

#include<stdio.h>
#include<string.h>

int main()
{
    char * c = "GATECSIT2017";
    char *p = c;
    printf("%d", (int)strlen(c+2[p]-6[p]-1));
    return 0;
}

The Output of the following program is____

Note: This question appeared as Numerical Answer Type.
(A) 1
(B) 2
(C) 4
(D) 6


Answer: (B)

Explanation:



c + 2[p] -6[p] -1
= c + p[2] –p[6] -1
= c + T – I – 1
= c + 11 -1
= c + 10
strlen(17) = 2


Quiz of this Question



My Personal Notes arrow_drop_up