Sunday, December 9, 2012

WAP to sort integer array in Descending and Ascending Order 36


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

void main()
{



int i,j,no;
char c[3],ch;
clrscr();

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

for(i=0;i<no;i++)
{
p("C[%d]=",i);
s("%c",&c[i]);
}

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

for(j=i+1;j<=no;j++)
{

if(c[i]>c[j]);
{

ch=c[i];
c[i]=c[j];
c[j]=ch;
}

}

}

for(i=0;i<no;i++)
{
p("\n%c",c[i]);
}

getch();

}

No comments:

Post a Comment