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

Input and output in c++, C++ improves on many of C's features and provides ...

C++ improves on many of C's features and provides object-oriented programming capabilities used for software production, quality and reusability. C++ was developed by Bjarne Strons

Cin, how we use the cin command and why we use this command????

how we use the cin command and why we use this command????

Fundamental input - output routines getc and putc, Access to the channel/de...

Access to the channel/devices is achieved by means of general purpose I/O routines Theses are standard functions described in stdio.h header file namely getc and putc. Getc and put

M - algorithm corrections, Of course it is C[i] = A[i] + B[i].It was a typi...

Of course it is C[i] = A[i] + B[i].It was a typing mistake,never mind. You just understand the concept. 27-1 b. for grain-size=1 n=A.length grain-size=1 r=n for

C program for bubble sort, C program for bubble sort: void main() {...

C program for bubble sort: void main() { int i,j,k,a[10],n; clrscr(); printf("How many values you want to enter\n"); scanf("%d",&n);  for(i=0;i  {  pri

Wap in c to find determinant of matrix order 3x3 , Normal 0 fal...

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

Write in a file - c program, Write in a file: void main() { int ...

Write in a file: void main() { int i,j,k,l,list[1000]; FILE *fp; char any[8];   cout cin >> any;   fp = fopen(any,"wb");     for(j=0;j     {

Return by reference, Return by reference: The return value of the funct...

Return by reference: The return value of the function must be an address variable.  In following program the function returns the value of x or y and their types are declare

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