shimmy_yaz
03-30-2005, 02:46 PM
How would I output all the letters in the alphabet using a while loop?
|
Click to See Complete Forum and Search --> : output all letters in alphabet shimmy_yaz 03-30-2005, 02:46 PM How would I output all the letters in the alphabet using a while loop? buntine 03-30-2005, 07:03 PM You simply need to use a loop to run through the ASCII codes of each character in the alphabet. Just convert each code into its alpha equivlant. for (int i=97; i<123; i++) System.out.println((char)i); If a while loop is imperative, use this: int i = 97; while (i < 123) System.out.println((char)i++); Regards. shimmy_yaz 03-31-2005, 08:20 AM yeah i figured it out once i really thought about it. i just did: System.out.println("All letters in alphabet in upper case letters:"); int A = 65; int Z = 90; while (A <= Z) { System.out.print((char)A + " "); A++; } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |