Insertion Sort Program in C++ With Source Code


#include<stdio.h>
#include<conio.h>

void main()
{
    int i,pointer=0,n=5,list[5],temp;
    clrscr();

    i=0;

    while(i<n)
    {
        printf("Enter the List[%d] Value:",i);
        scanf("%d",&list[i]);

        temp=list[i];
        pointer=i-1;

        while(temp<list[pointer])
        {
            list[pointer+1]=list[pointer];
            list[pointer]=temp;
            pointer=pointer-1;
        }

        for(int k=0;k<=i;k++)
        {
            printf("The value of List[%d]:%d\n",k,list[k]);
        }

        i++;
    }

    getch();
}
Insertion Sort Program in C++ With Source Code Insertion Sort Program in C++ With Source Code Reviewed by Unknown on 5:45:00 PM Rating: 5

No comments:

Powered by Blogger.