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
solve mesh and nodal analysis through c/c++?

A: Use references when you can use, and use pointers when you have to. References are generally preferred over pointers whenever you don't require "reseating". Usually this mean

can we use const data member in static. member function with example.

Explain the Formatted Input Output with Strings? These are the third set of the scanf and printf families. They are called sscanf and sprintf. sprintf Puts formatted dat

#questThere 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 doin

What is  T y pe C a s t Op er a t o r :   T h e f l o a t c a n b e c o n v e r t e d t o i n t e g e r v a l u

Write a program that counts from 0 to 99 and prints these numbers to the terminal ie it prints 00, 01, 02, 03, 04, 05, ....,99. Graphics 1. Write a program in rPeANUt that

Create a program WordCount1Main.java doing the following:  For each word in the le word.txt { Create an object of the class Word { Add the object to a set of the type java.uti

big-m method operation reseach in progrmme c++..

The definition of an object(variable ): We can explain a variable(set memory to the variable) in the following ways. e.g. double salary; int month; When more than o