navigation

Descending Order Using Selection Sort

   This is a program for Perform Selection Sort in descending Order
   Method : 
          in 1 st phase : 
              In This we Selction first element and compare with all no ..if any number is greater thn replace it with first one that.
          in Second phase :
             we take second number and comare with remaining ones ..if any number is greater thn replace it with second one.
          this process so on .. 
          see below program.
#include<stdio.h>
#include<conio.h>
#define max_size 10
int main()
{
     int arr[max_size],i,tmp_no,j;
     printf("Enter 10 Numbers ");
      for(i=0;i<max_size;i++)
     {
        printf("Enter Number  %d : ",i+1);
        scanf("%d",&arr[i]);
     }  
     for(i=0;i<max_size-1;i++){
        for(j=i+1;j<max_size;j++)
          {
            if(arr[i]<arr[j]){
                tmp_no = arr[i];
                arr[i] = arr[j];
                arr[j]= tmp_no;
                }
            }
     }
      printf("\nYour Array in descending Order : ");             
        for(i=0;i<max_size;i++)
         {
          printf("\n Number %d : %d",i+1,arr[i]);               
         }
      getch();
     return 0;
 }
Download Source file : selection_sort_descending.c
other impotent links : Ascending order using selection sort, Descending order using selection sort
keywords : Ascending and descending program using selection sort, selection sort, selection sort in c, sorting in c, Ascending and descending in array .
Descending Order Using Selection Sort Descending Order Using Selection Sort Reviewed by Unknown on 03:02 Rating: 5

No comments:

Powered by Blogger.