..

FreePrograms


  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

C programming Tutorial : Free C Programs, C Programs Download

Selection sorting Technique

#include<stdio.h>//header file
#include<conio.h>//header file
void main()
{
int i,l,a[10],j,t;
clrscr();
printf("enter the length of the list");
scanf("%d",&l);
printf("enter the elements in the list");
for(i=0;i<l;i++)//for loop
scanf("%d",&a[i]);
for(i=0;i<l-1;i++)
{
for(j=i+1;j<l;j++)
{
if(a[i]>a[j])//if(condition)
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf("the elements after selection sorting is=");
for(i=0;i<l;i++)
printf("%d ",a[i]);
getch();

}

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM