Coding Practice

Write a Java program to print all alphabets from a to z. - using while loop

Print all alphabets from a to z. - using while loop
Sample Output
Print all alphabets from a to z. - using while loop.
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Java-Source Code
//package loopinjava;

public class Main {

    public static void main(String[] args) {
        
        char ch;
        
        System.out.println("Print all alphabets from a to z. - using while loop.");

        ch = 'a';
        while (ch <= 'z') {
            System.out.println(ch);
            ch++;
        }
    }
}
Sample Output
Print all alphabets from a to z. - using while loop.
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

No comments:

Post a Comment

Change Theme
X