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

Assignment Help:

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

      


Related Discussions:- C program for sorting of long word with different string

HASH., Define hash functions. Explain the Division method, Mid square metho...

Define hash functions. Explain the Division method, Mid square method and Folding method of hash functions.

Miss, Depreciation to a salvage value of 0. For tax purposes an item m...

Depreciation to a salvage value of 0. For tax purposes an item may be depreciated over a period of several years, n. With the straight line method of depreciati

C program for sorting of long word with different string, C Program for SOR...

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]

Explain multidimensional arrays, Multidimensional Arrays - Every dimens...

Multidimensional Arrays - Every dimension is specified in separate brackets e.g. int arr[4][3]; This is a two-dimensional array with 4 as row dimension and 3 as

Application to maintain soccer team information, Write a C program "team.c"...

Write a C program "team.c" that maintains information for a soccer team. The program will allow you to add and delete players from your team, to search your team for players by nam

Vogels approximation transportation problem, Vogels approximation transport...

Vogels approximation transportation problem in c language source code

Define procedure that take argument or return integral value, Simpson's Rul...

Simpson's Rule is a more accurate method of numerical integration than the method described in class. Using Simpson's Rule, the integral of a function f between a and b is approxim

Conversion operator, What is conversion operator? Explain it with example.

What is conversion operator? Explain it with example.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd