Saturday 9 July 2016

C Programme for sorting data using array

 
 
Download .C file at the end of the post. 
/* WAP to take 5 numbers from the user and sort it in ascending order and
print result. */

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,j,temp;
clrscr();
printf("\nEnter data one by one");
  for(i=0;i<5;i++)
  {
   scanf("%d",&a[i]);
  }
//for sorting

for(i=0;i<5;i++)
{
 for(j=i+1;j<5;j++)
  {
   if(a[i]>a[j])
    {
     temp=a[i];
     a[i]=a[j];
     a[j]=temp;
    }
  }
}
 printf("\nData arranged in ascending order");
 for(i=0;i<5;i++)
  {
    printf("\t%d",a[i]);
  }
getch();
}
 
 
Download .C file of above programme - CLICK HERE

0 comments:

Post a Comment

Have A Wonderful Day !

--------------------------------------------------------------------

Word Of The Day | Learn And Use A New Word Everyday!

--------------------------------------------------------------------

"Insidious"

Working or spreading in a hidden and usually injurious way

"glaucoma is an insidious disease"

Copyright © 2016 Engineers Burger - All Rights Reserved. Digital Craftmanship - Nikhil Jha and Jay Akbari.
MyBloggerLab.com