the program is as follow
#include<stdio.h>
#define MAX 10
int main()
{
int arr[MAX],i,j,n,temp;
printf("Enter the no of element ");
scanf("%d",&n);
printf("enter the no:");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
printf("sorted no of ascending order :\n");
for(i=0;i<n;i++)
{
printf("%5d",arr[i]);
}
getch();
return 0;
}
the output is

#include<stdio.h>
#define MAX 10
int main()
{
int arr[MAX],i,j,n,temp;
printf("Enter the no of element ");
scanf("%d",&n);
printf("enter the no:");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
printf("sorted no of ascending order :\n");
for(i=0;i<n;i++)
{
printf("%5d",arr[i]);
}
getch();
return 0;
}
the output is
No comments:
Post a Comment
Note: only a member of this blog may post a comment.