473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

putting letters of a word in alphabetical order ?

8
Hi,
How would I write a function that gets leeters of a word in to alphabetical order using ANSI C? I heard something about using ascii but am still stuck . Thank you.
Nov 27 '06 #1
2 1560
Manjiri
40
Hi,
How would I write a function that gets leeters of a word in to alphabetical order using ANSI C? I heard something about using ascii but am still stuck . Thank you.

Tru out this... U will get the ans...

#include<stdio.h>

int main()
{
char a[30],c;
int i,j,l;
printf("Enter the word\n");
gets(a);
l=strlen(a);
for(i=0; i<l-1; i++)
{
for(j=i+1; j<l; j++)
{
if(a[i]>a[j])
{
c=a[i];
a[i]=a[j];
a[j]=c;
}
}
}
printf("Given word is arrenged in alphabetical order\n");
for(i=0; i<l; i++)
printf("%c",a[i]);
printf("\n");
return 0;
}
Nov 28 '06 #2
kara18
8
Thanks a lot ! Very helpful.
Nov 28 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Johannes Nix | last post by:
Hello, yesterday I met a cute person (after my dance class) who told me about an interesting experiment regarding cognition. People were told to read a typed text; However, in every word in the...
1
by: Eric Lilja | last post by:
Hello, in my program I need to ask the user to input some alphabetical letters. Case should not matter. Any input that isn't an alphabetical letter should be rejected and the user prompted to try...
7
by: Ron Adam | last post by:
I have several applications where I want to sort lists in alphabetical order. Most examples of sorting usually sort on the ord() order of the character set as an approximation. But that is not...
10
by: ckpoll2 | last post by:
Hello, I have a report that returns document numbers in the format "AA999999". These numbers are not in alphabetical and then numerical order. How can I put these in order? Thanks, Charlie
4
Cyberdyne
by: Cyberdyne | last post by:
In your All Programs Menu, some of your programs are in alphabetical order and others are not. This makes it very difficult to seek out a program that may be hidden in a maze of program folders and...
3
by: Danzak | last post by:
Can anyone out there help me with a problem I’m having? I have a database with 10117 records in it. Each record is numbered from 0001NHP to 10117NHP. Sometimes I have the database in alphabetical...
10
by: mdmytryk | last post by:
Simple question here. Im trying to figureout how to write a program in such a way that when a word is entered, the output is each individual letter of that word in a random order. so if pizza is...
1
by: sumone14 | last post by:
I have to create a program that opens a file and I have to find and show the words that have the most letters. I got the file to open but I can't figure out how to count the letters. I think I have...
2
by: pavanip | last post by:
Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.