Sunday, June 18, 2017

Positions of substring in the String

#include <stdio.h>
#include <string.h>

char str[100], sub[100];
int count = 0, count1 = 0;
int position[100];

void main()
{
    int i, j, l, l1, l2;

    printf("\nEnter a string : ");
    scanf("%[^\n]s", str);

    l1 = strlen(str);

    printf("\nEnter a substring : ");
    scanf(" %[^\n]s", sub);

    l2 = strlen(sub);

    for (i = 0; i < l1;)
    {
        j = 0;
        int temp = i;
        count = 0;
        while ((str[i] == sub[j]))
        {
            count++;
            i++;
            j++;
        }
        if (count == l2)
        {
            position[count1] = temp;
            count1++;                                  
            count = 0;
            i = temp + 1;
        }
        else
            i = temp + 1;
    }
   
    printf("%s occurs %d times in %s", sub, count1, str);
    int x;
    for(x=0;x< 100;x++)
    {
        if(position[x]==0){
            break;}
       
        printf("\n %d \t", position[x]);
    }
}

Thursday, February 13, 2014

Static variable example in C

/*  
  * static_c.c  
  *   
  * Copyright 2014 Afiz   
  *   
  *   
  */  
 #include <stdio.h>  
 void statfunc();   
 int main(int argc, char **argv)  
 {  
      int i=0;   
      for(i=0;i<10;i++)  
           statfunc();   
      return 0;  
 }  
 void statfunc()  
 {  
      static int stat_var=0;   
      int local_var =0;   
      printf("static valuce = %d\t Normal Variable =%d\n",stat_var, local_var);  
      stat_var++;   
      local_var++;   
 }  

Tuesday, October 1, 2013

Linked List Program in C


/*
LinkedList.c: this program is implementation of LinkedList in C. 

Date: 02/10/2013. 

*/


#include<stdio.h>
#include<string.h> 

void CreateNode(); 
void InsertElements(); 
void DisplayElements();
void DeleteElement(int a);

typedef struct 
{
 int data; 
 struct Node *next; 
}Node;

typedef Node *List;
List head,tail,temp; 

int main()
{
 int choice,data;  
 temp =NULL; head =NULL ; tail =head; 
 while(1){
 printf("==Linked List Menu==\n1.Insert Element\n2.Display\n3.Delete\n4.Exit\n");
 scanf("%d",&choice); 
 switch(choice)
 {
 case 1:
  InsertElements(); 
  break; 
 case 2:
  DisplayElements();
  break;
 case 3:
  printf("Enter the number that you want to delete\n");  
  scanf("%d",&data);
  DeleteElement(data); break; 
 default:
  printf("Thanks for using My programming ..\n");
  exit(0); 
 }
 }// end of infinite loop  


 return 0; 
}

void CreateNode()
{

 int data; 
 printf("Enter your element\n"); 
 scanf("%d",&data);
 temp = (List)malloc(sizeof(Node)); 
 temp->data = data; 
 temp->next =NULL; 
 
} 
void InsertElements()
{
 CreateNode(); 
 if(head == NULL)
 {
  head = temp; 
  tail =head; 
 }
 else 
 {
  tail->next = temp; 
  tail = tail->next;  
 }
}
void DisplayElements()
{
 if(head!=NULL)
 {
  printf("Elements===>\n");
 for(temp =head; temp!= NULL ; temp = temp->next)
  {
   printf("%d\t",temp->data);
  }
  printf("\n");
 }
 else
 {
  printf("Your Linked List Empty\n");
 }
}

void DeleteElement(int a)
{
 if(head!=NULL)
 {
  if(head->data == a)
  {
   head = head->next;
  }
  else{
   tail = head; 
   temp = head->next; 
   int found =0; 
  while(temp !=NULL)
   {
    if(temp->data ==a)
     {
     tail->next = temp->next;
 
          printf("element is found\\deleted\nPlease use option 2 to see remaining");
     found =1;     
     break;  
            }  
     else
     {
      tail = temp; 
      temp = temp->next;  
            }   
   }
   if(!found)
   printf("element is not present\n");   
      
      }
  
 
 }
 else
 {
  printf("Your Linked List Empty\n");
 }
}

Monday, March 11, 2013

SORTING ARRAY OF 0 AND 1 WITH ONE LOOP example in C


source code:

#include <stdio.h>

int main(int argc, char **argv)
{
   
    int a[]={1,1,1,1,0,0,0,0,1,1};  
      int j=0,i; 
      for(i=0;i<10;i++) 
      { 
           if(a[i]==0) 
           { 
             a[i]=1; 
            a[j++]=0;                
           } 
      } 
     for(i=0;i<10;i++)
      printf("%d\n",a[i]);
    return 0;
}

Sunday, March 10, 2013

Functions in C examples

 A function provides a convenient way to encapsulate some computation, which can then be used without worrying about its implementation. With properly designed functions, it is possible to ignore how a job is done; knowing what is done is sufficient. C makes the sue of functions easy, convenient and efficient; you will often see a short function defined and called only once, just because it clarifies some piece of code.


 A function definition Syntax:   
 return-type function-name(parameter declarations, if any)  
 {  
   declarations  
   statements  
 }  
 Example:   
 /*  
 power.c: This program will give you brief idea about functions.   
 Author: Afiz S   
 Date: 11/08/10  
 */  
 #include  
 int power(int a, int b); //prototype of the function.   
 main()  
 {  
 int a,b;  
 printf("Enter your 2 number base and exponent\n");  
 scanf("%d%d",&a,&b);  
 printf("%dpower %d is = %d\n",a,b,power(a,b)); // calling function.   
 }  
 int power(int a, int b) // function defination   
 {  
 int i,base=a;  
 for(i=1;i  
  {  
  //printf("%d\n",a);  
  a=a*base;  
  }  
  return a;  
 }  

C format specifiers


Format Specifiers in C
%i or %d int
%c char
%f float
%lf double
%s string
%hi short
%ld long int
%d,%hu unsinged short
%u unsinged int


  • \n (newline)
  • \t (tab)
  • \v (vertical tab)
  • \f (new page)
  • \b (backspace)
  • \r (carriage return)

Format Specifier for int and short in C example

 /*  
  * FormatSpecifiers.c  
  * Copyright 2013 Afiz <afiz@afiz-Extensa-4620>  
  */  
 #include <stdio.h>  
 int main(int argc, char **argv)  
 {  
      int a =109990909;   
      short b = 23;  
      printf("%d,%hi\n",a,b);  
      return 0;  
 }  

Monday, March 12, 2012

Facts about Sorting Techniques

 Bubble sort: comparisons O(n2), Swaps O(n2)  
 Selection Sort: Comparisons O(n2), swaps O(n)  
 Insertion Sort: Comparisons O(n2) , no swaps   
 Insertion sort is best basic sorts.  

Selection Sort example program in C

 /*  
 This is a basic program of Selection sort.  
 Author: Afiz  
 Date:  
 */  
 #include<stdio.h>  
 main()  
 {  
 int a[5]={9,7,4,8,1};// array with 5 elements.  
 int out,in,min,i;// local variable declarations   
 for(out =0;out<4;out++)// outer loop   
      {  
           min =out;   
      for(in=out+1;in<5;in++)// inner loop   
           {  
                if(a[in]<=a[min])  
                     min=in;   
           }  
      int tmp = a[min]; // swap ....   
      a[min]=a[out];  
      a[out]=tmp;  
      }  
 //printing array   
 for(i=0;i<5;i++)  
 {  
      printf("%d\n",a[i]);   
 }  
 }  

Insertion Sort Example program in C

 /*  
 This is a basic program of Insertion sort.  
 Author: Afiz  
 Date:  
 */  
 #include<stdio.h>  
 main()  
 {  
 int a[5]={9,7,4,8,1};// array with 5 elements.  
 int out,in,min,i;// local variable declarations   
 for(out=1;out<5;out++) // outer loop   
      {  
           temp = a[out];  
           in =out;   
      while(in>0 && a[in-1]>=temp) // inner loop   
           {  
                a[in]=a[in-1];  
                --in;   
           }  
           a[in]=temp;   
      }  
 //printing array ..   
 for(i=0;i<5;i++)  
      {  
           printf("%d\n",a[i]); //   
      }  
 }  

Bubble Sort example program in C

 /*  
 This is a basic program of Bubble sort.  
 Author: Afiz  
 Date:  
 */  
 #include<stdio.h>  
 main()  
 {  
 int a[5]={5,5,1,7,-1}; // array with 5 elements.  
 int i,j; // local variable declarations   
 for(i=0;i<5;i++)// outer loop   
 {  
      for(j=1;j<5-i;j++) // outter loop   
           {  
                if(a[j-1]>=a[j])  
                {  
                     int tmp = a[j-1]; // swap   
                     a[j-1]=a[j];  
                     a[j]=tmp;       
                }  
           }  
 }  
 //printing array   
 for(i=0;i<5;i++)  
 {  
      printf("%d\n",a[i]);   
 }  
 }  

Friday, April 8, 2011

Doubly Linked List Program in C

 /* Doubly linked list */  
 /* This program seg,ent creates a doubly linked list then prints in forward and backword */  
 /* Double_l.c */  
 #include <stdio.h>  
 #include <malloc.h>  
 void main(void)  
 {  
      int i;  
      struct ListEntry {  
           int number;  
           struct ListEntry *next;  
           struct ListEntry *previous;  
      } start, *node;  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      for (i = 1; i <= 10; i++)  
      {  
           node->next = (struct ListEntry *) malloc(sizeof(struct ListEntry));  
           node->next->previous = node;  
           node = node->next;  
           node->number = 50+i;  
           node->next = NULL;  
      }  
      /* Display the list */  
      node = start.next;  
      do {  
           printf("%d ", node->number);  
           node = node->next;  
      } while (node->next); /* Show 60 only one time */  
      do {  
           printf("%d ", node->number);  
           node = node->previous;  
      } while (node->previous);  
 }  

Merging Two Doubly Linked Lists

 /* MERGING TWO DOUBLY LINKED LISTS (ASCENDING ORDER) */  
 /* DBL_MRG.C */  
 # include <stdio.h>  
 # include <malloc.h>  
 struct Double  
 {  
      int info;  
      struct Double *next;  
      struct Double *previous;  
 };  
 int i;  
 struct Double start, start1, *new1, *local;  
 void Doubly_insertion (struct Double * );  
 void Doubly_Create (struct Double * );  
 void Display (struct Double *);  
 /* Function create a list of five nodes */  
 void Doubly_Create (struct Double *node)  
 {  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      for (i = 1; i < 10; i += 2)  
      {  
           node->next = (struct Double *) malloc(sizeof(struct Double ));  
           node->next->previous = node;  
           node = node->next;  
           node->info = i;  
           node->next = NULL;  
      }  
 }  
 void Doubly_insertion (struct Double *node)  
 {  
      struct Double *new1;  
      start1.next = NULL; /* Empty list */  
      start1.previous = NULL;  
      new1 = &start1;   /* Point to the start of the list */  
      for (i = 2; i <= 10; i += 2)  
      {  
           new1->next = (struct Double *) malloc(sizeof(struct Double ));  
           new1->next->previous = new1;  
           new1= new1->next;  
           new1->info = i;  
           new1->next = NULL;  
      }  
      new1 = start1.next;  
      printf("\n Second list is as follows");  
      while(new1)  
      {  
           printf("\n 0x%x", new1);  
           printf(" %d", new1->info);  
           new1 = new1->next;  
      }  
      new1 = start1.next;  
      while(new1)  
      {  
           int found = 0;  
           local = (struct Double *) malloc(sizeof(struct Double));  
           local = new1;  
           new1 = new1->next;  
           node = start.next;  
           do  
           {  
                if ( node->info > local->info )  
                {  
                     local->next = node;  
                     local->previous = node->previous;  
                     node->previous->next = local;  
                     node->previous = local;  
                     found = 1;  
                     break;  
                }  
                else  
                     node = node->next;  
           } while ((node->next) && (! found));  
           if (! found)  
                if (node->info> local->info)  
                {  
                     local->next = node;  
                     local->previous = node->previous;  
                     node->previous->next = local;  
                     node->previous = local;  
                }  
                else  
                {  
                     local->next = NULL;  
                     local->previous = node;  
                     node->next = local;  
                }  
      }  
 }  
 /* Display the list */  
 void Display (struct Double *node)  
 {  
      node = start.next;  
      while (node)  
      {  
           printf("\n 0x%x", node);  
           printf(" %d", node->info);  
           node = node->next;  
      }  
 }  
 /* Function main */  
 void main()  
 {  
      struct Double *node = (struct Double *) malloc(sizeof(struct Double));  
      Doubly_Create (node);  
      printf("\n First list is as follows\n");  
      Display (node);  
      Doubly_insertion (node);  
      printf("\n List after merging above two lists (Ascending order)\n");  
      Display (node);  
 }  

Creating Simple Doubly LInked List

 /* CREATING A SIMPLE DOUBLY LINKED LIST */  
 /* DBLINK.C */  
 # include <stdio.h>  
 # include <malloc.h>  
 struct Double  
 {  
      int info;  
      struct Double *next;  
      struct Double *previous;  
 };  
 int num ;  
 struct Double start;  
 void Doubly_link_list (struct Double *);  
 void display (struct Double *);  
 /* Function creates a simple doubly linked list */  
 void Doubly_link_list(struct Double *node)  
 {  
      char ch;  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      num = 0;  
      printf("\n Input choice n for break: ");  
      ch = getchar();  
      while( ch != 'n')  
      {  
           node->next = (struct Double *) malloc(sizeof(struct Double));  
           node->next->previous = node;  
           node = node->next;  
           printf("\n Input the values of the node : %d: ", (num+1));  
           scanf("%d", &node->info);  
           node->next = NULL;  
           fflush(stdin);  
           printf("\n Input choice n for break: ");  
           ch = getchar();  
           num ++;  
      }  
      printf("\n Total nodes = %d", num);  
 }  
 /* Display the list */  
 void display (struct Double *node)  
 {  
      node = start.next;  
      do {  
           printf("\n 0x%x", node);  
           printf(" %d", node->info);  
           node = node->next;  
      } while (node->next); /* Show value of last node only one time */  
      do {  
           printf("\n 0x%x", node );  
           printf(" %d", node->info);  
           node = node->previous;  
      } while (node->previous);  
 }  
 void main()  
 {  
      struct Double *node = (struct Double *) malloc(sizeof(struct Double));  
      Doubly_link_list(node);  
      printf("\n Created doubly linked list is as follows\n");  
      display(node);  
 }  
    

Inserting Nodes in the Doubly Linked List

 /* INSERTING SOME NODES IN THE DOUBLY LINKED LIST */  
 /* DBL_IL.C */  
 # include <stdio.h>  
 # include <malloc.h>  
 struct Double {  
      char info;  
      struct Double *next;  
      struct Double *previous;  
 };  
 int i;  
 struct Double start, *new1;  
 void Doubly_insertion_Last (struct Double *);  
 void Doubly_Create_Last (struct Double *);  
 void Display (struct Double *);  
 /* Function create a list of five nodes */  
 void Doubly_Create_Last (struct Double *node)  
 {  
      int i = 0;  
      char ch;  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      printf("\n Input choice n for break: ");  
      ch = getchar();  
      while (ch != 'n')  
      {  
           node->next = (struct Double *) malloc(sizeof(struct Double ));  
           node->next->previous = node;  
           node = node->next;  
           printf("\n Input the value for: %d: ", i+1);  
           scanf("%c", &node->info);  
           node->next = NULL;  
           i++;  
           fflush(stdin);  
           printf("\n Input choice n for break: ");  
           ch = getchar();  
      }  
 }  
 void Doubly_insertion_Last (struct Double *node)  
 {  
      node = start.next;  
      new1 = (struct Double *) malloc(sizeof(struct Double ));  
      fflush(stdin);  
      printf("\n Input the last node value: ");  
      scanf("%c", &new1->info);  
      if (node == NULL)  
      {  
           printf("\n List is empty\n");  
           printf("\n Insert as last node\n");  
      }  
      else  
           while(node)  
           {  
                node = node->next;  
           }  
      new1->next = node;  
      new1->previous = node->previous;  
      node->previous->next = new1;  
      node->next = new1;  
 }  
 /* Display the list */  
 void Display (struct Double *node)  
 {  
      node = start.next;  
      while (node)  
      {  
           printf("\n 0x%x", node);  
           printf(" %c", node->info);  
           node = node->next;  
      }  
 }  
 /* Function main */  
 void main()  
 {  
      struct Double *node = (struct Double *) malloc(sizeof(struct Double));  
      Doubly_Create_Last (node);  
      printf("\n Created list is as follows\n");  
      Display(node);  
      Doubly_insertion_Last (node);  
      printf("\n List after insertion of last node \n");  
      Display (node);  
 }  
    

Inserting First Node in Doubly Linked List

 /* INSERTING FIRST NODE IN THE DOUBLY LINKED LIST */  
 /* DBL_IF.C */  
 # include <stdio.h>  
 # include <malloc.h>  
 struct Double  
 {  
      char info[20];  
      struct Double *next;  
      struct Double *previous;  
 };  
 int i;  
 struct Double start, *new1;  
 void Doubly_insertion_First (struct Double *);  
 void Doubly_Create_First (struct Double *);  
 void Display (struct Double *);  
 /* Function create a list of five nodes */  
 void Doubly_Create_First (struct Double *node)  
 {  
      int i = 0;  
      char ch;  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      fflush(stdin);  
      printf("\n Input choice n for break: ");  
      ch = getchar();  
      while (ch != 'n')  
      {  
           node->next = (struct Double *) malloc(sizeof(struct Double ));  
           node->next->previous = node;  
           node = node->next;  
           printf("\n Input the value for: %d: ", i+1);  
           gets(node->info);  
           node->next = NULL;  
           i++;  
           fflush(stdin);  
           printf("\n Input choice n for break: ");  
           ch = getchar();  
      }  
 }  
 void Doubly_insertion_First (struct Double *node)  
 {  
      node = start.next;  
      new1 = (struct Double *) malloc(sizeof(struct Double ));  
      fflush(stdin);  
      printf("\n Input the first node value: ");  
      gets(new1->info);  
      printf("\n new1 address: 0x%x", new1);  
      printf("\n Node address: 0x%x", node);  
      new1->next = node;  
      printf("\n New1 next address: 0x%x", new1->next);  
      printf("\n Node previous address: 0x%x", node->previous);  
      new1->previous = node->previous;  
      node->previous->next = new1;  
      printf("\n node->previous.next: 0x%x", node->previous->next);  
      printf("\n Node previous address: 0x%x", node->previous);  
      printf("\n Node next address: 0x%x", node->next);  
      printf("\n new1 address: 0x%x", new1);  
      node->previous = new1;  
      printf("\n node->previous: 0x%x", node->previous);  
 }  
 /* Display the list */  
 void Display (struct Double *node)  
 {  
      node = start.next;  
      while (node)  
      {  
           printf("\n 0x%x", node);  
           printf(" %s", node->info);  
           node = node->next;  
      }  
 }  
 /* main function */  
 void main()  
 {  
      struct Double *node = (struct Double *) malloc(sizeof(struct Double));  
      Doubly_Create_First (node);  
      printf("\n Created list is as follows\n");  
      Display(node);  
      Doubly_insertion_First (node);  
      printf("\n List after insertion of first node \n");  
      Display (node);  
 }  

Delete Node from a Doubly Linked List

 /* DELETE A NODE FROM A SIMPLE DOUBLY LINKED LIST */ 
 # include <stdio.h>  
 # include <malloc.h>  
 struct Double  
 {  
      char info;  
      struct Double *next;  
      struct Double *previous;  
 };  
 int num ;  
 struct Double start;  
 void Doubly_Link_Del (struct Double *);  
 void Doubly_Link_Creat (struct Double *);  
 void display (struct Double *);  
 /* Function creates a doubly linked list */  
 void Doubly_Link_Creat (struct Double *node)  
 {  
      char ch;  
      start.next = NULL; /* Empty list */  
      start.previous = NULL;  
      node = &start;   /* Point to the start of the list */  
      num = 0;  
      printf("\n Input choice n for break: ");  
      ch = getchar();  
      while(ch != 'n')  
      {  
           node->next = (struct Double *) malloc(sizeof(struct Double));  
           node->next->previous = node;  
           node = node->next;  
           printf("\n Input the values of the node: %d:", (num+1));  
           scanf("%d", &node->info);  
           node->next = NULL;  
           fflush(stdin);  
           printf("\n Input choice n for break: ");  
           ch = getchar();  
           num ++;  
      }  
      printf("\n Total nodes = %d", num);  
 }  
 /* Function delete */  
 void Doubly_Link_Del (struct Double *node)  
 {  
      int delete_node;  
      int search_counter = 0;  
      printf("\n Input the node number to which you want delete: ");  
      scanf("%d", &delete_node);  
      node = start.next;  
      if ( node == NULL)  
      {  
           printf("\n Underflow\n");  
           printf("\n List is empty\n");  
      }  
      else  
           while(node)  
           {  
                if((search_counter + 1) == delete_node)  
                {  
                     node->previous->next = node->next ;  
                     node->next->previous = node->previous ;  
                     free(node);  
                }  
                else  
                {  
                     node = node->next;  
                }  
                search_counter++;  
           }  
 }  
 /* Display the list */  
 void display(struct Double *node)  
 {  
      node = start.next;  
      while (node)  
      {  
           printf("\n 0x%x", node);  
           printf(" %d", node->info);  
           node = node->next;  
      }  
 }  
 /* Function main */  
 void main()  
 {  
      struct Double *node = (struct Double *) malloc(sizeof(struct Double));  
      Doubly_Link_Creat(node);  
      printf("\n Created linked list is as follows\n");  
      display(node);  
      Doubly_Link_Del(node);  
      printf("\n After deletion of a node linked list is as follows\n");  
      display(node);  
 }   

CREATING CIRCULAR HEADER LINKED LIST in C

 /* CREATING CIRCULAR HEADER LINKED LIST */  
 /* CIRCLIST.C */  
 # include <stdio.h>  
 # include <malloc.h>  
 struct link  
 {  
      int info;  
      struct link *next;  
 };  
 int i; /* Represents number of nodes in the list */  
 int number;  
 struct link *start, *new1;  
 void insertion(struct link *);  
 void create_circular_list(struct link *);  
 void display(struct link *);  
 /* Function create a circular header linked list */  
 void create_circular_list( struct link *node)  
 {  
      char ch;  
      node = start;   /* Point to the header node in the list */  
      node->next = (struct link *) malloc(sizeof(struct link));  
      i = 0;  
      printf("\n Input choice n for break: ");  
      ch = getchar();  
      while(ch != 'n')  
      {  
           node->next = (struct link* ) malloc(sizeof(struct link));  
           node = node->next;  
           printf("\n Input the node: %d:", (i+1));  
           scanf("%d", &node->info);  
           fflush(stdin);  
           printf("\n Input choice n for break: ");  
           ch = getchar();  
           i++;  
      }  
      printf("\n Total nodes = %d", i);  
      node = start;  
      node->info = i; /* Assign total number of nodes to the header node */  
 }  
 /* Inserting a node in circular header linked */  
 void insertion(struct link *node)  
 {  
      int count = node->info;  
      int node_number = 0;  
      int insert_node;  
      node = start;  
      node = node->next;  
      printf("\n Input node number you want to insert: ");  
      printf("\n Value should be less are equal to the");  
      printf("\n number of nodes in the list: ");  
      scanf("%d", &insert_node);  
      while(count)  
      {  
           if((node_number+1) == insert_node)  
           {  
                new1 = (struct link* ) malloc(sizeof(struct link));  
                new1->next = node->next ;  
                node->next = new1;  
                printf("\n Input the node value: ");  
                scanf("%d", &new1->info);  
                node = node->next;  
                count--;  
           }  
           else  
           {  
                node = node->next;  
                count--;  
           }  
           node_number ++;  
      }  
      if (count == 0)  
      {  
           node = start; /* Points to header node */  
           node->info = node->info+1;  
      }  
 }  
 /* Display the list */  
 void display(struct link *node)  
 {  
      int count = node->info;  
      node = start;  
      node = node->next;  
      while (count-1)  
      {  
           printf("\n 0x%x", node);  
           printf(" %d ", node->info);  
           node = node->next;  
           count --;  
      }  
 }  
 /* Function main */  
 void main()  
 {  
      struct link *node = (struct link *) malloc(sizeof(struct link));  
      create_circular_list(node);  
      printf("\n Before inserting a node list is as follows:\n");  
      display(node);  
      insertion(node);  
      printf("\n After inserting a node list is as follows:\n");  
      display(node);  
 }