Difference between revisions of "Print Out the Alphabet"
From CompSciWiki
Line 4: | Line 4: | ||
Use the following guidelines in coming up with a solution: | Use the following guidelines in coming up with a solution: | ||
* [[Common Primitive Variables|char]] for printing out the each lowercase letter in the alphabet. | * [[Common Primitive Variables|char]] for printing out the each lowercase letter in the alphabet. | ||
− | * | + | * Output using [[Input/Output using System.out.|System.out.println]] |
* [[Comments|Commenting]] our code. | * [[Comments|Commenting]] our code. | ||
Revision as of 14:03, 6 April 2010
Back to the Program-A-Day homepage
ProblemPrint out the entire lower case letters of the aplhabet. Use the following guidelines in coming up with a solution:
|
While and For Loops | |
---|---|---|
SolutionTo 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 |