Skip to main content

Posts

Showing posts from December 16, 2017

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;