Posts

Showing posts from 2011

DOUBLY LINKED LIST

DOUBLY LINKED LIST PROGRAMMING IN C #include<stdio.h> #include<conio.h> #include<ctype.h> #include<stdlib.h> void create(); void insert(int); void delet(int); void display(); int ch,pos; char ch1; struct link { int data; struct link *llink,*rlink; }*start,*end,*temp; void main() { start=end=NULL; while(ch!=6) { clrscr(); printf("\n\tDOUBLY LINKED LIST\n"); printf("\n1.Creation \n2.Insertion \n3.Deletion \n4.Display \n5.Exit"); printf("\nEnter your choice:"); scanf("%d",&ch); switch(ch) { case 1: create(); break; case 2: printf("\nEnter the postion"); scanf("%d",&pos); insert(pos); break; case 3: printf("\n[B]ackward list"); printf("\n[F]orward list"); ch1=toupper(getch()); display(); printf("\nEnter the position:"); scanf("%d",&pos); delet(pos); break; case 4: printf("\n[B]ackward list"); prin

CIRCULAR LINKED LIST

CIRCULAR LINKED LIST PROGRAM: #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node { int info; struct node *next; }*first=NULL,*last=NULL; unsigned int count; int main(void) { int choice; void create(void); void insert(void); void rem(void); void display(void); printf("\n\tCircular Linked List"); do { clrscr(); printf("\n\toperations"); printf("\n\t1.create\n\t2.insert\n\t3.remove\n\t4.display"); printf("\n\t5.exit"); printf("\n\tEnter your choice:"); scanf("%d",&choice); switch(choice) { case 1: create(); break; case 2: insert(); break; case 3: rem(); break; case 4: display(); break; case 5: printf("Exited"); getch(); return 0; default: printf("Enter(1-5)only"); getch(); } } while(1); } void create(void) { struct node *temp=NULL; int n; if(first!=NULL) { printf("\nlist is not empty"); getch(); retur

PROCESS CREATION (In Linux/Unix)

PROCESS CREATION   PROGRAM: #include<stdio.h> #include<conio.h>             main(int argc,char *argv[]) {             int pid;             pid=fork(); if(pid<0) {             fprintf(stderr,”Fork failed”);             exit(-1); } else if(pid==0)             execlp(“/bin/ls”,”ls”,NULL) else {             wait(NULL):             printf(“Child completed”); } exit (0); }

OPERATING SYSTM’s ALGORITHM (In LINUX OS) - PRODUCER CONSUMER PROBLEM

PRODUCER CONSUMER PROBLEM PROGRAM: #include<stdio.h> #include<string.h> main() { int i,size,count=0,c,x=1,no,h,buf[100]; printf(“\nEnter the buffer size”); scanf(“%d”,&size); do { printf(“\n1.Produce\n2.Consume\n3.View produced item\n4.Exit”); printf(“\nEnter your choice”); scanf(“%d”,&c); switch(c) {             case 1:                         if(count>=size)                                     printf(“\nBuffer is full”);                         else                         {                         printf(“\nEnter the number of elements to be produced”);                                     scanf(“%d”,&no);                                     if((count+no)>size)                                                 printf(“\nEnter the number less than %d”,(size-count+1)); else { h=count; for(i=++h;i<=(h+no-1);i++) {             printf(“\nEnter the value”);             scanf