jituTechnology

jituTechnology

Write a program to sort the data in ascending and descending order using selection sort.

/*program to sort the data in  ascending order using selection sort.
Programmed by :Jitendra Kumar Yadav
roll ni.: 10116
programmed on.: 21st mar,2011*/
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j,temp;
int arr[10]={2,1,6,5,8,4,9,7,10,3};
for (i=0;i<9;i++)
{
for (j=i+1;j<9;j++)
{
if(arr[i]>arr[j])//for descending change > to <
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for (i=0;i<9;i++)
printf (“\n%d”,arr[i]);
getch();
}

Add a comment

Comments (1)

  1. Geraldo AtwellApril 5, 2012 Reply
    I’ve been exploring for a bit for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this web site. Reading this info So i’m happy to convey that I have a very good uncanny feeling I discovered exactly what I needed. I most certainly will make sure to don’t forget this site and give it a look regularly.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

October 2019
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031