Sunday, December 9, 2012

WAP that sort integer array in Ascending order 35


#include<stdio.h>
#include<conio.h>
#define p printf
#define s scanf

void main()

{

int i,j,aray[10],no,t;
clrscr();

p("\nEnter No...");
s("%d",&no);
p("\nEnter Array Elements...\n");

for(i=0;i<no;i++)
{
p("\nArray[%d]",i);
s("%d",&aray[i]);

}

for(i=0;i<no;i++)

{

for(j=i+1;j<=no;j++)
{
if(aray[i]>aray[j])
{

t=aray[i];
aray[i]=aray[j];
aray[j]=t;

}
}

}

for(i=0;i<no;i++)
{
p("\nAray[%d]=%d",i,aray[i]);
}

p("\n\n\tpress any key for exit...");
getch();

}

No comments:

Post a Comment