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 to find whether a number is odd or even, PROGRAM TO FIND WHETHER A ...

PROGRAM TO FIND WHETHER A NUMBER IS ODD OR EVEN int main() { int number ; printf("Enter a whole number\n"); scanf("%d",&number); if(number % 2 == 0) printf("n

Palindrome, A palindrome is a string that reads the same from both the ends...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Keywords in cpp, Define Keywords in C++ K e y w o r d s: ...

Define Keywords in C++ K e y w o r d s: K e y w o rd s a r e t h e w o rd s a l r e a d y u s e d b y C + + i n i t s c

Area under curve., write a c progrm to find area under the cuve y=f(x)  ...

write a c progrm to find area under the cuve y=f(x)   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; in

The square roots of the integers from 1 to 100, Assume we wish to partition...

Assume we wish to partition the square roots of the integers from 1 to 100 in to two piles of fifty numbers every, such that the sum of the numbers in the first pile is as close as

Insertion sort - c program, Insertion sort - C program: Write a progra...

Insertion sort - C program: Write a program in c to define a insertion sort. void main()  {   clrscr();   int a[100],ch,n;   cout   cin>>n;   for (int i=0

Define register variables - low level programming, Define Register Variable...

Define Register Variables - Low Level Programming? The Register variables are a special case of an automatic variable. The Automatic variables are allocated storage in the memo

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