vvdvdvdv

mail@pastecode.io avatar
unknown
c_cpp
a month ago
434 B
3
Indexable
Never
#include<stdio.h>
#include<conio.h>
void main()
{
	int a[100], size, i, j, t;
	clrscr();
	printf("Enter the size of array: ");
	scanf("%d", &size);
	printf("Enter the elements: ");
	for(i=0;i<size;i++)
		scanf("%d", &a[i]);
	for(i=1;i<size;i++)
	{
		j=i;
		while((j>0) && (a[j]<a[j-1]))
		{
			t = a[j];
			a[j] = a[j-1];
			a[j-1] = t;
			j--;
		}
	}

	for(i=0;i<size;i++)
		printf("%d ", a[i]);
	getch();
}
Leave a Comment