C program for sorting of long word with different string, C/C++ Programming

C Program for SORTING OF LONG WORD WITH DIFFERENT STRING

#include stdio.h>

#include conio.h>

#include string.h>

 

void main()

{

          char n[50],c[25][25];

          int i=0,j=0,k=0,temp,t=0,t1=0,l[25],l1[25];

          clrscr();

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

          {

                   for(j=0;j<25;j++)

                   {

                             l[i]=0;

                             l1[i]=0;

                             c[i][j]='0';

                   }

          }

          i=0;    j=0;

          printf("ENTER THE STRING= ");

          do

          {

                   n[i++]=getchar();

          }while(n[i-1]!='\n');

 

          n[i-1]='\0';

 

          for(i=0;n[i]!='\0';i++)

          {

                   if(n[i]!=' ')

                   {

                             l[t]=l[t]+1;

                             l1[t]=t+1;

                             c[t][t1++]=n[i];

                   }

                   else

                   {

                             t++;

                             t1=0;

                   }

          }

          for(i=0;l[i]!=0;i++)

          {

                   for(j=0;l[j]!=0;j++)

                   {

                             if(l[i]>l[j])

                             {

                                      temp=l[i];

                                      l[i]=l[j];

                                      l[j]=temp;

                                      temp=l1[i];

                                      l1[i]=l1[j];

                                      l1[j]=temp;

                             }

                   }

          }

 

          for(i=0;l[i]!=0;i++)

          {

                   for(j=0;l[j]!=0;j++)

                   {

                             if(l1[i]==j+1)

                             {

                                      for(k=0;c[j][k]!='0';k++)

                                      {

                                                printf("%c",c[j][k]);

                                      }

                                      printf("\n");

                             }

                   }

          }

          getch();

}

 

OUTPUT :

ENTER THE STRING: KAMLESH

ENTER THE STRING: MENGAR

ENTER THE STRING: JAMNAGAR

ENTER THE STRING: BCA

ENTER THE STRING: SEM2

 

JAMNAGAR

KAMLESH

MENGAR

SEM2

BCA

      

Posted Date: 9/10/2012 4:00:36 AM | Location : United States







Related Discussions:- C program for sorting of long word with different string, Assignment Help, Ask Question on C program for sorting of long word with different string, Get Answer, Expert's Help, C program for sorting of long word with different string Discussions

Write discussion on C program for sorting of long word with different string
Your posts are moderated
Related Questions
Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

My project is compiling but the equation entered is not working

Implement multiple stacks in a single dimensional array using c.

What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than a

Ask question #Minimum 100 words accepted program for polishing jewels#

Project Description: Online game development Online Live Baccarat Game is needed - client program. - server program(IOCP or ect..). - web program(ASP or PHP or etc..

Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''''a''''-''''z'''') and


Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec