The answer for your C programming exercise is given below.


#include <stdio.h>
#include <stdlib.h>
struct Node
{
	int data;
	struct Node *next;
};
struct Node *head = NULL;
void AddAtEnd(int );
void Traverse();
void main()
{
	AddAtEnd(10);
	AddAtEnd(20);
	Traverse();
	AddAtEnd(30);
	Traverse();
}
void AddAtEnd(int val)
{
	struct Node *ptr,*aptr = head,*bptr;
	if(head == NULL)
	{
		ptr = (struct Node *)malloc(sizeof(struct Node ));
		if(ptr == NULL)
		{
			printf("Req memory allocation failed\n");
		}else
		{
			ptr->data = val;
			ptr->next = NULL;
			head = ptr;
		}
	}else
	{
		ptr = (struct Node *)malloc(sizeof(struct Node ));
		if(ptr == NULL)
		{
			printf("Req memory allocation failed\n");
		}else
		{
			while(aptr != NULL)
			{
				bptr = aptr;
				aptr = aptr->next;
			}
			ptr->data = val;
			bptr->next = ptr;
			ptr->next = NULL;
		}
	}
}
void Traverse()
{
	struct Node *ptr = head;
	int n = 1;
	while(ptr != NULL)
	{
		printf("Node %d data %d\n", n,ptr->data);
		ptr = ptr->next;
		n++;
	}	
}