DIFFICULT IN ARRANGING SEQUENCE OF WORDS IN ALPHABETICAL ORDER? PERHAPS YOUR NAME?
- #include<iostream.h>
- #include<conio.h>
- #include<string.h>
- void main()
- {
- clrscr();
- char name[20],final[20];
- int number[20],order[20];
- cout<<"\nEnter the name..";
- cin>>name;
- int length=strlen(name);
- for(int i=0;i<length;i++)
- {
- number[i]=name[i];
- }
- int j=1,max=0;
- while(j<=length)
- {
- max=0;
- for(i=0;i<length;i++)
- {
- if(number[i]>max)
- {
- max=number[i];
- order[length-j]=max;
- }
- }
- for(int k=0;k<length;k++)
- {
- if(max==number[k])
- {
- number[k]=0;break;
- }
- }
- j++;
- }
- cout<<"\nAlphabetical order...";
- for(i=0;i<length;i++)
- {
- final[i]=order[i];
- cout<<final[i];
- }
- getch();
- }
IF YOU HAVE ANY DOUBTS OR ANY OTHER QUERIES YOU ARE FREE TO COMMENT BELOW.
No comments:
Post a Comment