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

Looping, Write a programme to display the patern.. A A B A C B A B C...

Write a programme to display the patern.. A A B A C B A B C A B A A

Write a c program to input three real numbers, Write a C program to input t...

Write a C program to input three real numbers and  print them out as follows : The first variable is ....... and the second one is ...... The last variable is .......... T

I need asp .net facebook app project completion, I need Asp .net Facebook a...

I need Asp .net Facebook app project completion Project Description: We are urgently seeking a few remaining items to be completed, and the project to be deployed to live.

Matrices, write a c program that multiplies 3 martices

write a c program that multiplies 3 martices

Board colouring, in this problem you are given a board in which some of the...

in this problem you are given a board in which some of the elements are placed..each element represent ancolor.fill the other elements in the board such that none of the adjacent e

Write a program that finds the minimum total number of shelv, At a shop of ...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Find area, #question.to determine the area of a triangle,rectangle and tra...

#question.to determine the area of a triangle,rectangle and trapezium

Define some features of register storage class in c program, Define some fe...

Define some features of register storage class in c program? The feature of variable defined to be of register type all as follows: Storage - CPU registers Default initia

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