11:03 AM
C++ Program for SORTING OF STRING

Write a Program of SORTING OF STRING

#include<iostream.h> 
#include<conio.h>

void main()

{

int i,j,n;

char str[20][20],temp[20];

clrscr();

puts("Enter the no. of string to be sorted");

scanf("%d",&n);

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

gets(str[i]);

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

for(j=i+1;j<=n;j++)

{

if(strcmp(str[i],str[j])>0)

{

strcpy(temp,str[i]);

strcpy(str[i],str[j]);

strcpy(str[j],temp);

}

}

printf("The sorted string\n");

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

puts(str[i]);

getch();

}

Note:
      If you want to change in this program please write through the comment on this page. you can also past similar program 
                 of c++ with output.your comment is valuable to the other user and person

Views: 118 | Added by: vijoriya | Tags: sorting, program, c++, String | Rating: 0.0/0
Total comments: 0
avatar