I need help with the following below: The program in Figure 2.40 below creates a
ID: 3550474 • Letter: I
Question
I need help with the following below:
The program in Figure 2.40 below creates a linked list whose elements are in reverse order
compared to their input order. Modify the first loop of the program to create the list in
the same order as the input order. Do not modify the second loop.
Sample Input
1 0 20 30 40 - 9999
Sample Output
1 0 20 30 40
Figure 2.40:
#include <iostream>
using namespace std;
struct node {
int data;
node* next;
};
int main ( ) {
node *first, *p;
int value;
first - 0;
cin >> value;
}
for (p - first ; p !- 0; p - p->next) {
cout << p->data ' ';
}
return 0;
Input
10 20 30 40 -9999
Output
40 30 20 10