Difference between revisions of "Print Out the Alphabet"

From CompSciWiki
Jump to: navigation, search
Line 13: Line 13:
 
|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.
  
<pre>
+
|Code=int numLetters = 26;
int numLetters = 26;
+
 
char letter = 'a';
 
char letter = 'a';
  
Line 22: Line 21:
 
     letter = letter + 1;
 
     letter = letter + 1;
 
}
 
}
</pre>
 
  
 
}}
 
}}

Revision as of 11:53, 1 April 2010

Back to the Program-A-Day homepage

Problem

You task is to print out the lower case letters of the aplhabet. You are only allowed to use one char variable and one println statement inside of a for loop.

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

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

Code

SolutionCode goes here. Please DO NOT put your code in <pre> tags!

Back to the Program-A-Day homepage