Posts

Ahahaha! This blog

Yea.. it is dead seriously.. I used to post code of C on blogger. that's just so lame.. The past me, huh! here's my github in any case for any fan of my high grade C programs made easy- Here.. click Here! Signing off... probably forever!

Selection Sort with step-by-step Output

Source Code #include <stdio.h> //defining the constant ASIZE as array's size #define ASIZE 10 void main() {     int i,j,key;          //var just for displaying the in-between arrays     int l;          //unsorted array     int a[ASIZE]={0,5,4,8,1,9,7,3,6,2};          // printing the unsorted array     printf("Unsorted Array: ");     for(i=0;i<ASIZE;i++)         printf("%d ",a[i]);     printf("\n\n");          //start of Selection Sort         //traversing the whole array     for(i=0;i<ASIZE;i++){                //taking position of i in a key variable         key=i;                  //gives the smaller element everytime one is found         printf("\nSmallest Element= %d", a[key]);                  //inner loop to find position of smallest digit                 //traversing the unsorted array         for(j=i+1;j<ASIZE;j++){             if(a[key]>a[j]){                 key=j;          

Insertion Sort with Run-Time Input & step-by-step Output

Source Code #include <stdio.h> #include <string.h> //Array size defined #define SIZE 8 //Insertion sort function int ins_sort(int a[],int n){     int j,key,i,k;     printf("Array_Before_Insertion_Sort:\n");     for(i=0;i<n;i++)             printf("%d ",a[i]);         printf("\n\n");          //Sorting Algorithm     for(j=1;j<n;j++){                  key=a[j];         printf("\nKey- %d\n",key);         i=j-1;                  while(i>=0 && a[i]>key){             a[i+1]=a[i];             i=i-1;             for(k=0;k<n;k++)                 printf("%d ",a[k]);             printf("\n");         }         a[i+1]=key;         for(i=0;i<n;i++)             printf("%d ",a[i]);         printf("\n");     } } //Main Function void main(){          int arr[SIZE];     int i;     for(i=0;i<SIZE;i++)         scanf("%d",&arr[

Geronimo!

I have seen too many posts and codes for various algorithms on the www, but none of them help us understand the code at really low level.. so, here, I'm going to post codes of various problems and algorithms in C language! Compile & Execute C Program Online   (about:  Blogpost )