Print Out the Alphabet

From CompSciWiki
Revision as of 16:22, 7 April 2010 by TimC (Talk | contribs)

Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

Print out the entire lower case letters of the aplhabet. Use the following guidelines in coming up with a solution:

 

While and For Loops

Wiki loops03.jpg


Solution

To get the next letter in the alphabet you can add 1 each time to the char variable.

int numLetters = 26;
char letter = 'a';

for(int i = 0; i < numLetters; i++)
{
    System.out.println(letter);
    letter = letter + 1;
}

Code

Solution Code

Back to the Program-A-Day homepage