Important to understand:-
1)
int *p = &a;
In this declaration, p will store the address of a & it only says that the expected value stored at 'a' is integer data type or in simple words, p is pointing to an address which contains integer data. But in practice, a could be anything (int, char, even it could be a structure). Try it yourself-
int a=101;
char *p=&a;
printf("%d",*p); output:- 101
2)
WHAT IS CHAR DATA TYPE:- A single letter of any kind is character whether it is a, b, 1, 5, %, $...
only ASCII value of the corresponding letter is stored at the given address. So single integer values are also allowed.
How to store a character into char data type. char a='f'; (by using single quote) & string using double quote("C-programming")
Now come back to question
LINE 1 struct Ournode p = {'1', '0', 'a'+2} ;
LINE 2 struct Ournode *q = &p ;
LINE 3 printf ("%c, %c", *((char*)q+1), *((char*)q+2)) ;
Here pointer q is defined as it is expecting an address of a structure of type ournode. So if we replace LINE 3 with this statement
printf("%c",*q); It will print 1st char data stored in the structure but if we replace LINE 3 with this
printf("%c",*(q+1)); it will jump to next record(skipping structure p completely) & won't print anything, because expected data of pointer q is structure so size of "struct Ournode" will be added to the address stored into pointer q.
Now replace LINE 3 with
printf ("%c", *((char*)q+1));
if we (Typecast) or change the expected type of the pointer p to char data type then it will not jump to the next record but will add the size of the char data to the address stored into pointer q. so "0" will be printed.
Option A is correct.
If we change LINE 2 & 3 with this...
char *q = &p;
printf ("%c, %c", *(q+1), *(q+2)) ;
then we don't even have to typecast the pointers, It will also work and produces the same result.