Solution
0 node
*addToEnd(node *first,char name[],int roll_no){
1 node *new_node=(node *)malloc(sizeof(node));
2 node *temp=first;
3
4 //initialise new node
5 strcpy(new_node->name,name);
6 new_node->roll_number=roll_no;
7 new_node->next=NULL;
8
9 //if the list is empty do this.
10 if(first==NULL){
11 first=new_node;
12 return first;
13 }
14
15 //traverse list
16 while(temp->next!=NULL){
17 temp=temp->next;
18 }
19
20 //attach node to end of the list
21 temp->next=new_node;
22 return first;
23 }
24
1 node *new_node=(node *)malloc(sizeof(node));
2 node *temp=first;
3
4 //initialise new node
5 strcpy(new_node->name,name);
6 new_node->roll_number=roll_no;
7 new_node->next=NULL;
8
9 //if the list is empty do this.
10 if(first==NULL){
11 first=new_node;
12 return first;
13 }
14
15 //traverse list
16 while(temp->next!=NULL){
17 temp=temp->next;
18 }
19
20 //attach node to end of the list
21 temp->next=new_node;
22 return first;
23 }
24