#include 
#include 
struct del
{
  int number;
  struct node *link;
};
typedef struct del node;
/*struct node *head;
struct node *new;
struct node *n1;
s
truct node *key;*/
void main()
{
   node *find(node *p,int a);
   int key;
   node *n1;
   node *head;
   node *new;
   node *p;
   printf("ENTER THE NODE TO BE DELETED\n");
   scanf("%d",&key);
   if(hea
   d->number == key)
   {
     new = (node*)malloc(sizeof(node));
     p = head->link;
     free(head);
     head = p;
   }
   else
   {
     n1 = find(head,key);
     if(n1 == NULL)
       printf("NODE IS NOT FOUND\m");
     else
     {
       p = n1->link->link;
       free(n1->link);
       n1->link = p;
     }
   }
}
node *find(node *list,int key)
{
   if(list->link->number == key)
      return list;
    else
      if(list->link->link == NULL)
 return NULL;
      else
  find(list->link,key);
}
All Programs in C
ShoutBox
Blog Archive
- 
▼ 
2010
            (22)
          
- 
▼ 
January
            (22)
          
- Linklist Node delete program in C
 - Link List program in c
 - Assembler program in C
 - Accessing array in C using pipe
 - Fork IPC program in C
 - Executing another program in C
 - Time program in C
 - Sorting Program in C using fork and pipe
 - Use of vfork in Unix C program
 - Fork and Wait in Unix IPC C program
 - Pipes in Unix IPC
 - Complete sum program in Unix IPC
 - Sort program in C using Unix IPC fork and pipe
 - Shared memory in Unix C program
 - Sum of N numbers program in C using Fork and Pipe IPC
 - Inter process communication with fork and pipe
 - Fork and Pipe program in C
 - Fork with Pipe Program in C
 - Another Fork program in C
 - Simple Fork Program in Linux/Unix C
 - Recursive File System Search Program in C
 - Assembler Program in C
 
 
 - 
▼ 
January
            (22)
          
 
Join With Me...
#include 
#include 
struct node
{
  int number;
  struct node *link;
};
struct node *head;
//struct node *next;
//struct node *prev;
//struct node *key;
void main()
{
   node *find(node *p,int a);
   int key;
   node *n1;
   node *p;
   printf("ENTER THE NODE TO BE DELETED\n");
   scanf("%d",&key);
   if(head->number == key)
   {
     p = head->link;
     free(head);
     head = p;
   }
   else
   {
     n1 = find(head,key);
     if(n1 == NULL)
       printf("NODE IS NOT FOUND\m");
     else
     {
       p = n1->link->link;
       free(n1->link);
       n1->link = p;
     }
   }
}
/*   if(first == NULL)
     printf("UNDERVLOW\n");
   else
   {
     temp = first;
     first = (struct node*)malloc(sizeof(struct node));
     while(temp != key && temp->link !=NULL)
     {
       prev = temp;
       temp = temp->link;
       if(temp != key)
  printf("NODE IS NOT FOUND\n");
       else
       {
  if(key == first)
    first = first->link;
  else
    prev->link = key->link;
    key->link = avail;
    avail = key;
       }
     }
   }
} */
#include 
#include 
#include 
void push(char [], int *, char [], int *);
char pop(char [], int *);
void push1(char, int *, char [], int *);
void main()
{
 int i=0,top=-1,k=1,j,n;
 char str[30],stack[20],lhs,rhs,ch;
 clrscr();
 printf("Enter the postfix expression: ");
 scanf("%[^\n]s",str);
 j = strlen(str);
 str[j] = '#';
 while(str[i] != '#')
 {
  if(isalpha(str[i]))
   push(str,&i,stack,&top);
  else
  {
   rhs = pop(stack,&top);
   lhs = pop(stack,&top);
   j = lhs;
   n = rhs;
   if(j >= 0 && j <= 9)
    printf("LOD T%d\n",lhs);
   else
    printf("LOD %c\n",lhs);
   if(n >= 0 && n <= 9)
   {
    switch(str[i])
    {
                                 case '+':
      printf("ADD T%d\n",rhs);
      break;
     case '-':
      printf("SUB T%d\n",rhs);
      break;
     case '*':
      printf("MUL T%d\n",rhs);
      break;
     case '/':
      printf("DIV T%d\n",rhs);
      break;
    }
   }
   else
   {
    switch(str[i])
    {
     case '+':
      printf("ADD %c\n",rhs);
      break;
     case '-':
      printf("SUB %c\n",rhs);
      break;
     case '*':
      printf("MUL %c\n",rhs);
      break;
     case '/':
      printf("DIV %c\n",rhs);
      break;
    }
   }
   ch = (char)k++;
   printf("STO T%d\n",ch);
   push1(ch,&i,stack,&top);
  }
 }
 getch();
}
void push(char str[], int *i, char stack[], int *top)
{
 (*top)++;
 stack[*top] = str[(*i)++];
}
char pop(char stack[], int *top)
{
 return stack[(*top)--];
}
void push1(char ch, int *i, char stack[], int *top)
{
 (*top)++; (*i)++;
 stack[*top] = ch;
}
#include
main()
{
 int p1[2],p2[2],i=1,t=100,t1,res=0;
int arr[]={1,2,3,4,5,6,7,8,9,10};
int pro;
printf("RESULT :  %d\n",i);
pipe(p1);
pro=fork();
if(pro==0)
{
printf("RESULT(T) :  %d\n",i);
read(p1[0],t1,2);
write(i,t1,2);
printf("AFTER %d",i);
}
else
{
write(p1[1],t,2);
}
}
main()
{
 int a[2];
int b[6]={1,2,3,4,5,6};
int p,tem1=0,tem2=0,i,j;
{
p=fork();
if(p==0)
{
for(j=0;j<6;j+=2)
printf("%d  \n  ", b[j]);
}
else
{
for(j=1;j<6;j+=2)
printf("%d  \n  ", b[j]);
}
}
printf("%d   %d",tem1, tem2);
}
#include
#include
#include
void main(void)
{
int MAXLINE = 1024;
char buf[MAXLINE];
pid_t pid;
int status;
printf("%%");
while(fgets(buf,MAXLINE,stdin)!=NULL)
{
 buf[strlen(buf)-1]=0;
 if(pid=fork()<0)
  err_sys("FORK ERROR");
 else if(pid==0)
 {
  execlp(buf,buf,(char *)0);
  err_ret("Couldn't Execute : %s",buf);
  exit(127);
 }
 if((pid=waitpid(pid,&status,0))<0)
  err_sys("Wait Pid Error");
 printf("%%");
}
exit(0);
}
 
#include
#include
int main()
{
 clock_t st,end;
 long i,j,t;
 st=clock();
 for(i=0;i<10000L;i++)
  for (j=0;j<50000L;j++)
  t=0; 
 end=clock();
 printf("\nSTARTING CLOCK: %lf",(double)st);
 printf("\nEnding Clock  : %lf",(double)end);
 printf("\n%lf",(double)((end-st)/CLK_TCK));
 return 0;
}
*/
#include
#include
main()
{
 clock_t st,en;
   int arr[10000],*ptr=arr,n,t;
     float fir[5],sec[5],res;
     unsigned long i,j;
      for(t=0;t<5;t++)
         {
           st=clock();
     for(j=0;j<10000L;j++)
       for(i=0;i<10000;i++)
         {
             arr[i]=1;
              }
     en =clock();
     printf("\nFIRST :  %lf\n",fir[t]=(en-st)/CLK_TCK);
     st=clock();
      for(j=0;j<10000L;j++)
        for(i=0;i<10000;i++)
          {
             *(ptr+i)=1;
              }
      en =clock();
      printf("SECOND: %lf",sec[t]=(en-st)/CLK_TCK);
      printf("\nDIFFERENCE  :  %lf\n",*(fir+t)-*(sec+t));
         }
     
      for(t=0;t<5;t++)
        res=res+*(fir+t)+*(sec+t);
       printf("\nTOTAL TIME IS : %lf\n",res);
       res=0;
      for(t=0;t<5;t++)
               res=res+(*(fir+t)-*(sec+t));
       printf("\nTOTAL TIME SAVE IS :%lf\n",res);
       printf("\n\nEND");
       return 0;
        }

