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

 

#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

 

Posted Date: 9/10/2012 4:18:04 AM | Location : United States







Related Discussions:- C program for sorting of character , Assignment Help, Ask Question on C program for sorting of character , Get Answer, Expert's Help, C program for sorting of character Discussions

Write discussion on C program for sorting of character
Your posts are moderated
Related Questions
A: In C, encapsulation was completed by making things static in a compilation unit or module. It prevented another module from accessing the static stuff. (Incidentally, now static

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

This assignment document will be distributed from Blackboard assignment folder. Some parts of the assignments will require you to research answers from your text book (you must rea

What is the difference among a copy constructor and an overloaded assignment operator? Ans) A copy constructor constructs a latest object by using the content of the argument


Discuss the saleint featuresand application of c

Define External Static Storage Class - Computer Programming? An external static is declared outside of all the functions and is obtainable to all functions in that program. The

Write a program that computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules. a. A call made between 8:00 AM and 6:

Project Description: Need someone to prepare a trading platform and sophisticated trading strategy. Must have knowledge and experience in most of these: QuickFIX, Esper, Quan

In this sub-task will you implement three functions for the final three function prototypes that will do exactly the same as the three functions that you have just written. This ti