Difference between revisions of "Print Out the Alphabet"
From CompSciWiki
Line 3: | Line 3: | ||
|Problem=Print out the entire lower case letters of the aplhabet. Use one char variable and one println statement inside of a for loop. | |Problem=Print out the entire lower case letters of the aplhabet. Use one char variable and one println statement inside of a for loop. | ||
+ | |SideSectionTitle=Blah | ||
|SideSection= | |SideSection= | ||
[[Image:Wiki_loops01.jpg|center]] | [[Image:Wiki_loops01.jpg|center]] | ||
− | |||
− | |||
− | |||
− | |||
|Solution= To get the next letter in the alphabet you can add 1 each time to the char variable. | |Solution= To get the next letter in the alphabet you can add 1 each time to the char variable. |
Revision as of 12:35, 6 April 2010
Back to the Program-A-Day homepage
ProblemPrint out the entire lower case letters of the aplhabet. Use one char variable and one println statement inside of a for loop. |
Blah | |
---|---|---|
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 |