About

Kannur University btech CSE study materials, question papers, syllabus . . .

Thursday, July 4, 2013

S4 HARDWARE LAB - TASM - SORTING

#include<stdio.h>
Void main()
{int l,i=0,t,j,a[10];
Clrscr();
Printf(“\n\n enter the limit”);
Scanf(%d”,&l);
Printf(“enter the elements”);
For(;i<l;i++)
Scanf(“%d”,&a[i]);
For(i=0;i<l;i++)
For(j=0;j<i;j++)
{
{if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
Printf(“\n ascending order”);
For(i=0;i<l;i++)
Printf(“%d”,a[i]);
For(i=0;i<l;i++)
For(j=0;j<i;j++)
{if(a[i]<a[j]);
{t=a[i];
a[i]=a[j];
a[j]=t;
}
}
Printf(“\n descending order”);
For(i=0;i<l;i++)
Printf(“%d”,a[i]);
getch();
}
OUTPUT
Enter the limit:6
Enter the numbers:1 2 20 41 10 20
Ascending order :1 2 10 20 20 41
Descending order:41 20 20 10 2 1








0 comments:

Post a Comment