4 4 votes Programming in C + – Rohan Mundhey 1.2k views answer comment Share Follow Print See all 2 Comments 2 2 Comments reply Habibkhan commented Nov 5, 2016 reply Follow flag Is it B) @Rohan Mundhey? 1 1 replyShare Rohan Mundhey commented Nov 5, 2016 reply Follow flag yes , its B 0 0 replyShare Please log in or register to add a comment.
Best answer 1 1 vote Here let us understand the meaning of each options . Option A) is meaningless as far as I know since it is variable name first before type which is totally wrong. Option B) says a function q which takes a pointer to character as parameter and then the return type is an array of integers..Since parantheses and array subscript operator have same precedence so associativity criterion is used..Since both of them are left to right associative , so compiler first interprets that there is a function whose set of parameter comprises of pointer to char data type and then on seeing the subscript operator it understands that the return type is pointer to an array of integers since there is a '*' before q. Option C) says a pointer to a function q which takes pointer to char as argument and the return type is an array of integers.So C) is also not true. Hence the correct option should be B). Habibkhan answered Nov 5, 2016 • selected Nov 5, 2016 by Rohan Mundhey Habibkhan comment Share Follow See all 5 Comments 5 5 Comments reply Show 2 previous comments Arjun commented Nov 5, 2016 reply Follow flag won't it be a pointer to a function returning int and taking char* as argument? 0 0 replyShare Habibkhan commented Nov 5, 2016 reply Follow flag The pointer to a function returning int and taking char* as argument will be written as : int (*q) (char*) ; So there is a parantheses outside *q and after that one more parantheses indicating that q is a pointer to a function which takes char* as argument and whose return type is int. 0 0 replyShare Arjun commented Nov 5, 2016 reply Follow flag yes, you are correct. But these 2 are the same and are valid: int (*q(char*)); int* q(char*); Both can be put in same C file and compiled with "-c" option to avoid linking. 2 2 replyShare Please log in or register to add a comment.