Skip to main content

Posts

COCKTAIL SORT ALGORITHM IN C PROGRAM

DOWNLOAD PROGRAM MORE DATA STRUCTURE PROGRAM IN C CODING: #include <stdio.h> #define MAX 8 int main() { int data[MAX]; int i, j, n, c; printf("\nEnter the data"); for (i = 0; i < MAX; i++) { scanf("%d", &data[i]); } n = MAX;    do { for (i = 0;  i < n - 1; i++) { if (data[i] > data[i + 1]) { data[i] = data[i] + data[i + 1]; data[i + 1] = data[i] - data[i + 1]; data[i] = data[i] - data[i + 1]; } } n = n - 1; for (i= MAX - 1, c = 0; i >= c; i--) { if(data[i] < data[i - 1]) { data[i] = data[i] + data[i - 1]; data[i - 1] = data[i] - data[i - 1]; data[i] = data[i] - data[i - 1]; } } c = c + 1; } while (n != 0 && c != 0); printf("The sorted elements are:"); for (i = 0; i < MAX; i++) { printf("%d\t", data[i]); } }

GNOME SORT ALGORITHM IN C PROGRAM

DOWNLOAD PROGRAM MORE DATA STRUCTURE PROGRAM IN C CODING: #include <stdio.h> void main() { int i, temp, ar[10], n; printf("\nenter the elemts number u would like to enter:"); scanf("%d", &n); printf("\nenter the elements to be sorted through gnome sort:\n"); for (i = 0; i < n; i++) scanf("%d", &ar[i]); i = 0; while (i < n) { if (i == 0 || ar[i - 1] <= ar[i]) i++; else { temp = ar[i-1]; ar[i - 1] = ar[i]; ar[i] = temp; i = i - 1; } } for (i = 0;i < n;i++) printf("%d\t", ar[i]); }

EXAMPLE OF C PROGRAMS

  1. Calculation of Roots of Quadratic Equation   2. Compare String   3. Compound Interest Calculation   4. Decimal to Binary Conversion   5. Decimal to Hexadecimal Conversion   6. Decimal to Octal Conversion   7. Depreciation Calculation   8. Floyd triangle pattern   9. Harmonic Number Series 10. Letter Count of a String 11. Pascal number triangle pattern 12. Print triangle pattern using asterix 13. Static Analysis in C++ 14. String Concatenation 15. Sum of numbers between 100 and 200 divisible by 7 16. Swap two numbers without using third 17. Vowel Count in a String

HEAP SORT ALGORITHM IN C PROGRAM

DOWNLOAD PROGRAM MORE DATA STRUCTURE PROGRAM IN C CODING: #include<stdio.h> #include<conio.h> #define max 11 void restore_heap_up(int *,int); void restore_heap_down(int *,int,int); void main() { int heap[max],n,i,j,temp; clrscr(); printf("How Many Number You want to ADD.->"); scanf("%d",&n); printf("Input Number.\n");  for(i=1;i<=n;i++)   {   printf("[%d]=",i);   scanf("%d",&heap[i]);   restore_heap_up(heap,i);   }  j=n;  for(i=1;i<=j;i++)   {    temp=heap[1];    heap[1]=heap[n];    heap[n]=temp;    n=n-1;    restore_heap_down(heap,1,n);   }  n=j;  printf("SORTED LIST IS...\n");  for(i=1;i<=n;i++)   {   printf("[%d]=%d\n",i,heap[i]);   } getch(); } void restore_heap_up(int *heap,int index) { int val=heap[index];  while((index>1) && (heap[index/2]<val))   {    heap[index]=heap[index/2];    index/=2;   }  heap[index]=val;

BINARY SEARCH TREE USING LINK LIST WITH CREATION,INSERTION & TRAVERSAL PRE-ORDER,IN-ORDER,POST-ORDER

DOWNLOAD PROGRAM CODING: #include<stdio.h> #include<conio.h> struct node { int data; struct node *left; struct node *right; }; struct node *tree=NULL; struct node *insert(struct node *,int); void preorder(struct node *); void inorder(struct node *); void postorder(struct node *); void main() { int ch,data; clrscr(); do {  printf("\n    ___MAIN MENU___");  printf("\n1.INSERTION");  printf("\n2.TRAVERSAL PRE-ORDER");  printf("\n3.TRAVERSAL IN-ORDER ");  printf("\n4.TRAVERSAL POST-ORDER");  printf("\n5.EXIT");  printf("\nENTER THE NUMBER:");  scanf("%d",&ch);  switch(ch)   {   case 1:   printf("ENTER THE DATA:");   scanf("%d",&data);   tree=insert(tree,data);   break;   case 2:   preorder(tree);   break;   case 3:   inorder(tree);   break;   case 4:   postorder(tree);   break;   case 5:   printf("PRESS ENTER FOR EXIT..

REVERSE THE STRING USING THE STACK

DOWNLOAD PROGRAM CODING: #include<stdio.h> #include<conio.h> #include<string.h> #define max 50 char string[max]; int top=-1; void push(char a); char pop(); void main() { char str[50]; int i; clrscr(); printf("ENTER THE VALID CHARCTER STRING:"); gets(str); for(i=0;i<strlen(str);i++)  push(str[i]); for(i=0;i<strlen(str);i++)  str[i]=pop(); printf("REVERSED STRING..."); puts(str); getch(); } void push(char s) { if(top==(max-1)) {  printf("STACK IS OVERFLOW..."); } string[++top]=s; } char pop() { if(top==-1) {  printf("STACK IS UNDERFLOW..."); } return string[top--]; }