PREVIOUS
Java source code
class Alphabets
{
public static void main(String args[])
{
char ch;
for( ch = 'a' ; ch <= 'z' ; ch++ )
System.out.println(ch);
}
}
Output of program:
Printing alphabets using while loop (only body of main method is shown):
char c = 'a';
while (c <= 'z') {
System.out.println(c);
c++;
}
Using do while loop:
char c = 'A';
do {
System.out.println(c);
c++;
} while (c <= 'Z');
No comments:
Post a Comment