Question: In C++ using the code below, write: 1) An iterative function (that is one that uses a loop) to display the data in each node
In C++ using the code below, write:
1) An iterative function (that is one that uses a loop) to display the data in each node
2) A recursive function to display the data in each node
_____________________-
#includeusing namespace std; struct Node { Node* next; int data; }; Node * ADDNODE(Node * N, int d) { Node * B = new Node; N->next = B; B->data = d; B->next = NULL; return B; } int main() { //Node NNode; Node *X = new Node; Node *Y = new Node; Node *Z = new Node; X->data = 10; Y =ADDNODE(X, 20); Z =ADDNODE(Y, 30); cout< data< next->data< next->next->data< next->next->next->data<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
