random letter generator

Matthew Smith msmith%peruvian.utah.edu at cs.utah.edu
Sat Oct 20 07:49:04 AEST 1990


In article <1990Oct17.120817.4636 at swbatl.sbc.com> uucigj at swbatl.sbc.com writes:
>I am in need  of a function that will return a random captial letter
>(A-Z).  This seems like an easy one, but it is eluding me.  Any help?
>
>Please email since I don't get a chance to read this group that often.
>
>      Gregg Jensen

How about generating a random number between 0 and 25, and adding 65 to it.
That would give you a range of 65 to 90, or ascii codes for A and Z.

num=25*random()+65;


Matt Smith



More information about the Comp.lang.c mailing list