Professional Documents
Culture Documents
DS P-3
DS P-3
DS P-3
h>
#include<conio.h>
void main()
{
int choice;
clrscr();
do
{
printf("\n\t\tProgram for Insertion and
Selection Sort \n");
printf("\n\tMain Menu: \n1.Insertion Sort\
n2.Selection Sort\n3.Exit");
printf("\nSelect menu : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
insertionsort();
break;
case 2:
selectionsort();
break;
case 3:
printf("\nExiting the program");
break;
void insertionsort()
{
int n, array[100], i, k, temp,ptr;
clrscr();
temp = array[i];
ptr = i-1;
getch();
void selectionsort()
{
int array[100],i,j,k,n,smallest,position,temp;
clrscr();
if(smallest == array[i])
{
printf("\n");
}
else
{
temp = array[i];
array[i] = smallest;
array[position]= temp;
}
printf("\n");
for(k=0;k<n;k++)
{
printf("\t%d",array[k]);
}
}
printf("\n\n Sorted Elements by selection sort:");
for(i=0;i<n;i++)
{
printf("\t%d",array[i]);
}
getch();