What will be the output of the following C code?#include int main(){struct p{char *name;struct p *next;};struct p *ptrary[10];struct p p, q;p.name = "xyz";p.next = NULL;ptrary[0] = &p;q.name = (char*)malloc(sizeof(char)*3);strcpy(q.name, p.name);q.next = &q;ptrary[1] = &q;printf("%s\n", ptrary[1]->next->next->name);}

🎲 Try a Random Question  |  Total Questions in Quiz: 143  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
C Programming Practice Test: Structures, Unions and Bit-Fields — practice the complete quiz, review flashcards, or try a random question.

Quiz questions on: Structures basics, functions, arrays of structures, pointer to structires, self referential structures, table lookup, typedefs, unions and bit fields. Structures: A structure is a user-defined data type that allows you to group together related data items. For example, you could create a structure to store information about a person, such as their name, age, and address. To declare a structure, you use the struct keyword followed by the name of the structure and a list of its members. Each member of a structure must have a type and a name. Once you have declared a... Show more

What will be the output of the following C code?<br>#include <stdio.h><br>int main()<br>{<br>struct p<br>{<br>char *name;<br>struct p *next;<br>};<br>struct p *ptrary[10];<br>struct p p, q;<br>p.name = "xyz";<br>p.next = NULL;<br>ptrary[0] = &p;<br>q.name = (char*)malloc(sizeof(char)*3);<br>strcpy(q.name, p.name);<br>q.next = &q;<br>ptrary[1] = &q;<br>printf("%s\n", ptrary[1]->next->next->name);<br>}