Question
Suppose we have a struct node defined as follows: struct node { int data; struct node * next; }; We also have a function named
Suppose we have a struct "node" defined as follows: struct node { int data; struct node * next; }; We also have a function named createNode that allocates a new node and sets its data field to the specified value. (The next field is set to NULL.) struct node * createNode(int val); Variable n1 points to a struct node that has already been created and initialized. Variable n2 is a struct node pointer, and its current value is NULL. Write a statement, or sequence of statements, that creates a new node, sets its data equal to 1 more than n1's data, and makes n1's next field point to the new node. (In the previous sentence, we've used "n1" to mean "the struct that n1 points to".) Do not change the value of n1.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started