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
# Dear I want help to programmer that write C++ code for my small project as soon as posible If we can help me?..

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

3 kilograms of peebles are needed for converting an area of 1 square meter.the rate of the peeble is 5 per kilogram

The procedure +, * and list take arbitrary numbers of arguments. One way to define such a procedure is to use define with dotted-tail notation. In a procedure definition, a paramet

write a prgm to find minimum total number of shelves including the intial one required for loading process

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Discuss the saleint featuresand application of c

how to create the programs in c++ knowledge

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

Implement, in rPeANUt, the a Fibonacci function by using the simple recursive approach. The Fibonacci function can be implemented in c as follow: int fib(int x) {   if (x