What will be the output of the following C code?#include struct student{char *name;};struct student s;struct student fun(void){s.name = "newton";printf("%s\n", s.name);s.name = "alan";return s;}void main(){struct student m = fun();printf("%s\n", m.name);m.name = "turing";printf("%s\n", s.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>struct student<br>{<br>char *name;<br>};<br>struct student s;<br>struct student fun(void)<br>{<br>s.name = "newton";<br>printf("%s\n", s.name);<br>s.name = "alan";<br>return s;<br>}<br>void main()<br>{<br>struct student m = fun();<br>printf("%s\n", m.name);<br>m.name = "turing";<br>printf("%s\n", s.name);<br>}