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

C Program for SORTING OF LONG WORD WITH ONE 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= ");

          flushall();

          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 D MENGAR

 KAMLESH

MENGAR

D

Posted Date: 9/10/2012 4:14:03 AM | Location : United States







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

Write discussion on C program for sorting of long word with one string
Your posts are moderated
Related Questions
how to create a flowchart? can you help me in my assignment about flowcharting ....

how to explain working of bus connection

HOW THE C PROGRAM CODING IMPLEMENTED DY ITSELF UNDERSTANDING . ALSO HOW I CAN A BECOME A GOOD PROGRAMMER IN C WHAT I DO FOR GOOD PROGRAMMING ,TELL ME HOW C CODING DEVELOP DY ITSELF

1. De ne a function chomp :: String -> String that selects a run of repeated characters from the start of a string with the run being as long as possible. For example ch

Project Description: Boots capture video from your YouTube channel and upload your own video to our channel or the copyright of the videos, bang, 3 parties, automatically delete

Introduction. In this assignment you are required to revisit the Assignment 1 topic. You will develop a new program which is more sophisticated, in particular, adding more functio

how many bytes required to char

Can you overload a function depend only on whether a parameter is a value or a reference? A: No. Passing by value and reference looks identical to the caller.

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

Need help finishing my homework. It''s been 5 years since I''ve use C++. I am a VN.Net programmer. -Todd