0% found this document useful (0 votes)
6 views1 page

Insetion Sort

The document contains a C program that implements the insertion sort algorithm. It prompts the user to enter the size and elements of an array, sorts the array using the insertion sort method, and then displays the sorted array. The code includes necessary functions and input/output operations for sorting and displaying the array elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Insetion Sort

The document contains a C program that implements the insertion sort algorithm. It prompts the user to enter the size and elements of an array, sorts the array using the insertion sort method, and then displays the sorted array. The code includes necessary functions and input/output operations for sorting and displaying the array elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

---------------------------

INSERTION SORT
---------------------------
#include<stdio.h>
void insertion(int a[],int n)
{
int i,j,item;
for(i=1;i<n;i++)
{
item=a[i];
for(j=i-1;(j>=0)&&(a[j]>item);j--)
{
a[j+1]=a[j];
}
a[j+1]=item;
}
}
int main()
{
int a[60],i,n;

printf("\n enter the size of the array::");


scanf("%d",&n);
printf("\n enter the elements of the array::");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
insertion(a,n);
printf("\n display::");
for(i=0;i<n;i++)
{
printf("%4d",a[i]);
}return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy