Wednesday, 8 January 2014

C program to sort 10 Array elements in descending order Using Array

# include<stdio.h>
# include<conio.h>
void main()
{
int arr[10];
int i,j,temp;
clrscr();
for(i=0;i<10;i++)
scanf("%d",&arr[i]);
for(i=0;i<9;i++)
{
  for(j=i+1;j<10;j++)
  {
   if(arr[i]<arr[j])
   {
   temp=arr[i];
   arr[i]=arr[j];
   arr[j]=temp;
   }
}
}
printf("\nSorted array elements :\n");
for(i=0;i<10;i++)
printf("%d ",arr[i]) ;
getch();
}

No comments:

Post a Comment