//WAP TO SORT THE CHARACTERS ALPHABATICALLY.
#include<conio.h>
#include<stdio.h>
void main()
{
char a[20];
int m,j,k,temp;
clrscr();
printf("\nENTER THE STRING:");
gets(a);
k=strlen(a);
for(j=1;j<=k-1;j++)
for(m=0;m<k-j;m++)
{
if(a[m]>a[m+1])
{
temp=a[m];
a[m]=a[m+1];
a[m+1]=temp;
}
}
printf("\n\nAFTER SORTING STRING IS:\n\n");
puts(a);
getch();
}
/*-------------------------------------------------------------------
OUTPUT
-------------------------------------------------------------------
ENTER THE STRING:BADCFEHGJILK
AFTER SORTING STRING IS:
ABCDEFGHIJKL
*/
#include<conio.h>
#include<stdio.h>
void main()
{
char a[20];
int m,j,k,temp;
clrscr();
printf("\nENTER THE STRING:");
gets(a);
k=strlen(a);
for(j=1;j<=k-1;j++)
for(m=0;m<k-j;m++)
{
if(a[m]>a[m+1])
{
temp=a[m];
a[m]=a[m+1];
a[m+1]=temp;
}
}
printf("\n\nAFTER SORTING STRING IS:\n\n");
puts(a);
getch();
}
/*-------------------------------------------------------------------
OUTPUT
-------------------------------------------------------------------
ENTER THE STRING:BADCFEHGJILK
AFTER SORTING STRING IS:
ABCDEFGHIJKL
*/
No comments:
Post a Comment