#include <stdio.h>
#include<conio.h>
void main()
{
int a[100], n, i, j,temp;
printf("Enter no, of element in array\n");
scanf("%d", &n);
printf("Enter the elements:-");
for (i= 0; i < n; i++)
scanf("%d", &a[i]);
for (i = 0 ; i < ( n - 1 ); i++)
{
for (j = 0 ; j< n - i - 1; j++)
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j]= a[j+1];
a[j+1] = temp;
}
}
}
printf("Sorted form:-");
for ( i = 0 ; i < n ; i++ )
printf("%d\n", a[i]);
}
#include<conio.h>
void main()
{
int a[100], n, i, j,temp;
printf("Enter no, of element in array\n");
scanf("%d", &n);
printf("Enter the elements:-");
for (i= 0; i < n; i++)
scanf("%d", &a[i]);
for (i = 0 ; i < ( n - 1 ); i++)
{
for (j = 0 ; j< n - i - 1; j++)
{
if (a[j] > a[j+1])
{
temp = a[j];
a[j]= a[j+1];
a[j+1] = temp;
}
}
}
printf("Sorted form:-");
for ( i = 0 ; i < n ; i++ )
printf("%d\n", a[i]);
}
No comments :
Post a Comment