Posts

Showing posts from November, 2017
Image
                                    C-PROGRAM   HEAP SORT #include<stdio.h> #include<stdlib.h> void heapify1(int *a, int lim) {int i,j,tmp,left,right,fg=0; i=1; while(fg==0){ left=2*i; right=(2*i)+1; if(right<=lim) { if(a[i]<a[left] || a[i]< a[right]){ if(a[left]>a[right]){ tmp=a[left]; a[left]=a[i]; a[i]=tmp; i=left; } else { tmp=a[right]; a[right]=a[i]; a[i]=tmp; i=right; }} else {fg=1;} }else if (left<=lim){ if(a[left]>a[i]){ tmp=a[left]; a[left]=a[i]; a[i]=tmp; i=left; } else{ fg=1; } }// end o
Image
                                    C-PROGRAM   LINKED LIST #include<stdlib.h> #include<stdio.h> struct node { int a; struct node *next; }; void display(struct node *temp) { printf("\n elements in the list are\n"); while(temp!=NULL) { printf("\t %d",temp->a); temp=temp->next; } } struct node *insert(struct node *start) { struct node *temp,*prev; int pos; temp=(struct node*)malloc(sizeof(struct node)); printf("enter the number of elements"); scanf("%d",&temp->a); printf("select the position to insert the number\n1.at the begning\n2.at the end\n3.at specified position"); scanf("%d",&pos); switch(pos) { case 1:temp->next=start; start=temp; break; case 2:prev=start; while(prev->next!=NULL) { prev=prev->next;} prev->next=temp; temp->next=NULL; break; case 3: printf("enter the position");
Image
                                    C-PROGRAM Queue- enqueue and dequeue #include<stdio.h> void main() { int a[10],front=0,rear=0,ch,i; do { printf("QUEUE OPERATIONS\n\t1.Enqueue\n\t2.Dequeue\n\t3.Display\nEnter your choice: "); scanf("%d",&ch); switch(ch) { case 1: if(rear==10) printf("Queue is already full: "); else { printf("Enter an element: "); scanf("%d",&a[rear++]); } break;      C tutorial video for beginners case 2: if(rear==0) printf("Queue is empty: "); else printf("Deleted element is %d",a[front]); for(i=0;i<rear;i++) a[i]=a[i+1]; rear--; break; case 3: if(rear==0) printf("Queue is empty: "); else { printf("Elements are \n"); for(i=0;i<rear;i++) printf("%d ",a[i]); } break; default: printf("Invalid entry: "); } printf("\nPress (1) to continue: &qu
Image
                                    C-PROGRAM   PROGRAM TO CHECK WHETHER ENTERED YEAR IS LEAP YEAR #include<stdio.h> void main() { int a; printf("enter the year to be checked"); scanf("%d",&a); if(a%4==0) { if(a%100==0) { if(a%400==0) printf("Leap year");      C tutorial video for beginners else printf("Not a leap year "); } else printf("Leap year"); } else printf("Not a leap year"); }                                                           C Tutorial For beginners FREE ZONE TUTOR.................................YOUR FEEDBACK IS OUR KEY TO SUCCESS..........FREE ZONE TUTOR.................................YOUR FEEDBACK IS OUR KEY TO SUCCESS...
Image
                                    C-PROGRAM   STACK-push & pop operation #include<stdio.h> void main() { int a[10],it,c,i,fr=0; do { printf("STACK \n 1.PUSH\n2.POP\n3.DISPLAY\nENTER YOUR CHOICE:"); scanf("%d",&c); switch(c) { case 1: if(fr<=9) { printf("enter the element"); scanf("%d",&it); a[fr++]=it; } else printf("stack overflow"); break;      C tutorial video for beginners case 2: if(fr>=0) { printf("the deleted item is %d",a[fr-1]); --fr; } else printf("stack is empty"); break; case 3: for(i=0;i<fr;i++) printf("%d",a[fr]); break; default: printf("invalid operation"); } printf("press 1 to continue"); scanf("%d",&c); }while(c==1); }