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

Assignment Help:

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


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

Develop an e commerce site, We need an E Commerce site likefifacointrader. ...

We need an E Commerce site likefifacointrader. you must have experience with that kind of work You have to show a sample of work like that site. Skills required are C Prog

Write a c program to input numbes in table format, Write a C program to inp...

Write a C program to input 16 numbers and print them out in a table format of 4 wide by 4 deep. E.g.   4    5    5    7   8    9    10    11   12    13    14    15   16    17

#c++, There is a pebble merchant. He sells the pebbles, that are used for s...

There is a pebble merchant. He sells the pebbles, that are used for shining the floor. His main duty is to take the length of the room’s sides. But he sometimes mistakes doing that

Program that predicts users age, Program: Write a program that predicts...

Program: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an

Described access privileges in c++? what is the default , A: In C++ the acc...

A: In C++ the access privileges are public, private and protected. The default access level assigned to members of a class is private. Private members of any class are accessible o

C program to demonstrate call by reference, C program to demonstrate call b...

C program to demonstrate call by reference: void disp(int *,int*,int*,int*); void main() {                 int a=2,b=3, sum,mul;                 printf("Enter 1st n

What is precedence and order of evaluation, Precedence and Order of evaluat...

Precedence and Order of evaluation The languages follow a standard precedence for basic operators. Precedence rules help in deleting ambiguity of the order of operations perfor

Wap for basic salary of employees & calculate net salary, WAP TO ACCEPT THE...

WAP TO ACCEPT THE BASIC SALARY OF EMPLOYEES & CALCULATE NET SALARY   #include stdio.h> #include conio.h>   void main() {                    float Basi

Define some features of static storage class in c program, Define some feat...

Define some features of static storage class in c program? The features of a variable defined to contain a static storage class are as follows. Storage - memory Default

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