hai, i have attached linked list program in 'c' along this post.... if u compile it will show 2 warning message, just ignore it and execute the program....
take care...
Code:
#include<conio.h>
#include<stdio.h>
void creation(int);
void display();
void insertion(int,int);
void deletion(int);

struct list
{
  int num;
  struct list *next;
}*head, *l;

void main()
{
  int n1,ch,pos,val;
  clrscr();
  printf("enter the no of nodes to be entered : ");
  scanf("%d",&n1);

  do
  {
     clrscr();
     printf("\n1.creation\n2.insertion\n3.deletion\n4.display\n5.exit\n");
     printf("\nenter ur choice : ");
     scanf("%d",&ch);
     switch(ch)
     {
	case 1:
		creation(n1);
		break;
	case 2:
		printf("\n\nenter the postion in which to be inserted : ");
		scanf("%d",&pos);
		printf("\n\nenter the value : ");
		scanf("%d",&val);
		insertion(pos,val);
		break;
	case 3:
		printf("\n\nenter the position to be deleted : ");
		scanf("%d",&pos);
		deletion(pos);
		break;
	case 4:
		display();
		getch();
		break;
	case 5:
		exit(0);
     }
  }while(ch!=5);

  getch();
}

/*  CREATION   */
/*  --------   */


void creation(int n1)
{
  int i,n;
  head=((struct list *)malloc(sizeof(struct list)));
  l=head;
  for(i=0;i<n1;i++)
  {
     printf("enter the %d node : ",i+1);
     scanf("%d",&n);
     l->num=n;
     l->next=((struct list *)malloc(sizeof(struct list)));
     l=l->next;
  }
  l->next=0;

}

/*  DISPLAY   */
/*  -------   */


void display()
{
  l=head;
  printf("\nthe nodes entered are : ");

  while(l->next>0)
  {
    printf("%d\t",l->num);
    l=l->next;
  }
  printf("null");
}


/*  INSERTION   */
/*  ---------   */

void insertion(pos,val)
{
  int i;
  struct list *x,*y;
  l=head;
  i=2;
  if(pos==1)
  {
    x=((struct list *)malloc(sizeof(struct list)));
    x->num=val;
    x->next=l;
    head=x;
  }
  else
  {
	while(l->next>0)
	{
	    if(pos==i-1)
	    {
	      x=((struct list *)malloc(sizeof(struct list)));
	      x->num=val;
	      x->next=l;
	      y->next=x;
	    }
	    y=l;
	    l=l->next;
	    i++;
	}
  }
}

/*  DELETION   */
/*  --------   */


void deletion(pos)
{
  int i;
  struct list *y;
  l=head;
  i=1;
  if(pos==1)
  {   head=l->next;  }
  else
  {
    while(l->next>0)
    {
      if(pos==i)
      { l=l->next;
	y->next=l;
	break;
      }
      y=l;
      l=l->next;
      i++;
    }
  }
}

Last edited by shabbir; 24Mar2007 at 09:42.. Reason: Code formating.