Insertion sort - c program, C/C++ Programming

Insertion sort - C program:

Write a program in c to define a insertion sort.

void main()

 {

  clrscr();

  int a[100],ch,n;

  cout<<"enter the limit for the array : ";

  cin>>n;

  for (int i=0;i

                {

                cout<<"enter element "<

                cin>>a[i];

                }

                clrscr();

                cout<<"1. insertion sorting "<

                isort(a,n);

                 }

 }

void isort(int a[100],int n)

 {

                 clrscr();

                int te,i,j;

                for(i=1; i

                  {

                   te=a[i];

                                j=i-1;

                                 while (te=0)

                                   {

                                   a[j+1]=a[j];

                                   j=j-1;

                                   }

                                  a[j+1]=te;

                  }

                   cout<<" sorted arrays by insertion "<<"\n\n";

                   for(i=0; i

                   cout<

                   getch();

 }

Posted Date: 10/19/2012 3:10:14 AM | Location : United States







Related Discussions:- Insertion sort - c program, Assignment Help, Ask Question on Insertion sort - c program, Get Answer, Expert's Help, Insertion sort - c program Discussions

Write discussion on Insertion sort - c program
Your posts are moderated
Related Questions
Can I drop the [] while deleteing array of some built-in type (char, int, etc)? A: No. you can't Sometimes programmers think that the [] in the delete[] p only present so the


Explain redirection in c++


Is there any difference between List x; and List x ()? Can you please provide me assignment help.

Greatest Common Divisor (GCD) - The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves intege


write a C++ program that performs the following tasks 1. prompts the user to enter two numbers 2. displays the divisors of each number and store the divisors of number 1 in A and t

Explain Rules for constructing variable names? The Rules for constructing variable names : a) A variable name is any combination of alphabets, 0 to 9 digits and undersc

Define  C o ns t a n t a r g u me n t : T h e a r gu m e n t c a n b e a c on s t a n t a r gu m e n t .    T h e c o