#include<stdio.h>
#include<conio.h>
void main()
{
int n,arr[100],i,j,temp=0;
clrscr();
//here first enter the size of the array
printf("enter the size of array");
scanf("%d",&n);
// enter the data in array
for(i=0;i<n;i++)
{
printf("\nenter the %d th data=",i+1);
scanf("%d",&arr[i]);
}
//bubble sorting can be implemented here
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
// after sorting display of the sorted list
printf("\nafter sorting");
for(i=0;i<n;i++)
{
printf("\n %d",arr[i]);
}
getch();
}
#include<conio.h>
void main()
{
int n,arr[100],i,j,temp=0;
clrscr();
//here first enter the size of the array
printf("enter the size of array");
scanf("%d",&n);
// enter the data in array
for(i=0;i<n;i++)
{
printf("\nenter the %d th data=",i+1);
scanf("%d",&arr[i]);
}
//bubble sorting can be implemented here
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
// after sorting display of the sorted list
printf("\nafter sorting");
for(i=0;i<n;i++)
{
printf("\n %d",arr[i]);
}
getch();
}
Post a Comment