C program for sorting of character , C/C++ Programming

Assignment Help:

 

#include stdio.h>

#include conio.h>

#include string.h>

 

void main()

{

          char a[50],b[25][25],l[25],temp1;

          int i=0,j=0,k=0,l1[25],c=0,c1=0,t=0,temp;

          clrscr();

          for(i=0;i<25;i++)

          {

                   for(j=0;j<25;j++)

                   {

                             l[i]='0';

                             l1[i]=0;

                             b[i][j]='0';

                   }

          }

          i=0;

          j=0;

printf("ENTER THE STRING= ");

flushall();

 

     do

          {

                   a[i++]=getchar();

          }while(a[i-1]!='\n');

          a[i-1]='\0';

          for(i=0;a[i]!='\0';i++)

          {

                   if(a[i]!=' ')

                   {

                             if(t==0)

                             {

                                      l[c]=a[i];

                                      t++;

                             }

                             l1[c]=c+1;

                             b[c][c1++]=a[i];

                   }

 

                   else

                   {

                             c++;

                             c1=0;

                             t=0;

                   }

          }

          for(i=0;l1[i]!=0;i++)

          {

                   for(j=0;l1[j]!=0;j++)

                   {

                             if(l[i]

                             {

                                      temp1=l[i];

                                      l[i]=l[j];

                                      l[j]=temp1;

                                      temp=l1[i];

                                      l1[i]=l1[j];

                                      l1[j]=temp;

                             }

                   }

          }

          for(i=0;l1[i]!=0;i++)

          {

                   for(j=0;l1[j]!=0;j++)

                   {

                             if(l1[i]==j+1)

                             {

                                      for(k=0;b[j][k]!='0';k++)

                                                printf("%c",b[j][k]);

                                      printf("\n");

                             }

                   }

          }

          getch();

}

OUTPUT :

ENTER THE STRING: KAMLESH D MENGAR

 D

KAMLESH

MENGAR

 


Related Discussions:- C program for sorting of character

Program of multipication using inline function, Aim: Write a program of mu...

Aim: Write a program of multipication using inline function class Multiply {           int x,y;           public:           void getdata();           inline calc

Read writers problem, Readers Writers with Processes and Threads Write two ...

Readers Writers with Processes and Threads Write two programs implementing ``reader pritority readers-writers synchronization'''' on files. One program will use processes, created

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Super ASCII String Cost, A string S is said to be "Super ASCII", if it cont...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

Array, how to pass array

how to pass array

Calculate the discharge by c program, #include stdio.h #include math.h ...

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

Operators and their expression in cpp, Operators in C++: All C operator...

Operators in C++: All C operators are valid operators in C++ also.  Besides C++ has developed some new operators like Operators and their Expression: 1.      Logical op

ARRAY, A PROGRAM TO CALCULATE AREA OF TRIANGLE

A PROGRAM TO CALCULATE AREA OF TRIANGLE

Structured design of programs, Within software engineering, software is ver...

Within software engineering, software is very rarely written by a single software engineer. Usually a team of engineers write a program; therefore a formal structural design approa

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