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
Implementing Operator Functions The general format of the Operator function is: return_type operator op ( argument list );   Where op is the symbol for the operator be

Question 1 Write a program that accepts two numbers from the user and swaps the two numbers without using a temporary variable Question 2 Write a program that accepts a 3x

em Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ''Content here, content here'', making it look like readable English. Many desktop publis

For your class to work properly, you'll need to define appropriate constructors, extract and insert operators, and of course arithmetic operators. (If you wanted to use it as a gen


Addition in a existing c++ unification algorithm Project Description: I have a existing code for a algorithm and need to add two modules into it, it is a unification algorith

Within C we access external devices by means of a pointer i.e. address. The address could point to any memory mapped device i.e. Ram, Rom, Duart, Disk drives etc. Therefore there i

Question : (a) (i) What is a structure member in C? What is the relationship between a structure member and the structure? (ii) How can structure variables be declared in C?

Program is to define a class as student: Program is to define a class as student and display the records specific depending upon the number class student  {  private:

Define the Int Data Type of C Language? The int is used to define integer numbers. The Integers are whole numbers with a range of values supported by a particular machine and t