Could any one send C++PROGRAM Given an array a={5, 10, 15, 20}, write a C++ code
ID: 3608884 • Letter: C
Question
Could any one send C++PROGRAMGiven an array a={5, 10, 15, 20}, write a C++ code to build alinklist with the values come from array a. Then using therecursive method to print the list in reverse order. Which meansthe 20 will be print out first, and 5 will be print outlast. Could any one send C++PROGRAM
Given an array a={5, 10, 15, 20}, write a C++ code to build alinklist with the values come from array a. Then using therecursive method to print the list in reverse order. Which meansthe 20 will be print out first, and 5 will be print outlast.
Explanation / Answer
//Hope this will help you.. #include using namespace std; struct node{ int n; struct node *next; }*first=NULL,*ptr; void insert(int *arr,int count) { int i; ptr=first; for(i=0;in = arr[i]; first->next=NULL; ptr=first; }else { ptr->next = new struct node; ptr=ptr->next; ptr->n = arr[i]; ptr->next=NULL; } } } void print_list(struct node *ptr){ if(ptr==NULL) return; print_list(ptr->next); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.