What is the output of given program?
#include <stdio.h>
#include <stdlib.h>
int main() {
    char *c = "GATECSIT2017";
    char *p=c;
    printf("%d",(int)strlen(c-6[p]+2[p]+1));
   return 0;
}
6Comments
Arijit Nandi @arijit11
11 Feb 2017 11:16 pm

how to solve ?

Pritam Prasun @pritam
11 Feb 2017 11:50 pm

Probably you forgot  #include <string.h>

Here, *c = "GATECSIT2017"  means, C is a character array.
char *p=c;   // Assigning array c into p

Now, 6[p] means p[6] so we can write,
c-6[p]+2[p]+1
c-p[6]+p[2]+1
c-'I'+'T'+1
c + ('T' - 'I') + 1 
c + 11 + 1  // ASCII of T - ASCII of I
c+12 // This will be pointing to null

So, strlen(c+12) should print 0.

Arijit Nandi @arijit11
12 Feb 2017 07:14 am

thank you sir. 

partha @pps121
12 Feb 2017 07:42 am

sir it was  strlen(c+p[6] - p[6]-1) , so it will be 2  

Pritam Prasun @pritam
12 Feb 2017 02:51 pm

Okay, So then answer will ofcourse change. But concept remains the same.

Haritha @harithachava
4 Aug 2018 11:15 pm
Sir here c means what value we should consider ?
Either ascii value or the adress