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
padovan string problem program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n, String str){        if(n >= 40)

Prepare an Application in C# or C++ Project Description: We are seeking someone who can write a program in C# or C++. The idea is to prepare the program using a Cross Plat

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

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

how made a flow chart of prime number by using for loop

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Describe spaghetti programming. - Spaghetti programming refers to codes which tend to get tangled and overlapped throughout the program. - It makes a program complex and ana

1. Using Visual C++ and your OpenGL configured environment, write an application that displays a “unique” graphical scene that you designed and coded for this course. What yo

Return by reference: The return value of the function must be an address variable.  In following program the function returns the value of x or y and their types are declare

Can you overload a function depend only on whether a parameter is a value or a reference? A: No. Passing by value and reference looks identical to the caller.