source file name: ArrSort.C
void main()
{
int i,j,temp;
int A[]={11,-20,23,77,-18,134,-53,500,6,100};
clrscr();
printf("unsoted given array numbers no :\n");
for(i=0;i<10;i++)
printf("%d ",A[i]);
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if(A[i]>A[j])
{
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
}
printf("\n array numbers in Ascnding order :\n");
for(i=0;i<10;i++)
printf("%d ",A[i]);
printf("\n array numbers in Descending :\n");
for(i=9;i>=0;i--)
printf("%d ",A[i]);
getch();
}
output:
0 Comments
Post a Comment