Algorithm


1. Set up a loop to iterate through the alphabets.
   a. Initialize a variable (e.g., 'char currentLetter') to represent the current alphabet.
   b. Use a loop (for or while) to iterate from 'A' to 'Z'.
      i. Inside the loop, print the current alphabet.
2. End the program.

Code Examples

#1 Code Example- Display uppercased alphabet using for loop

Code - Java Programming

class Main {
  public static void main(String[] args) {

    char c;

    for(c = 'A'; c  < = 'Z'; ++c)
      System.out.print(c + " ");
    }
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
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

#2 Code Example- Display lowercase alphabet using for loop

Code - Java Programming

class Main {
  public static void main(String[] args) {

    char c;

    for(c = 'a'; c  < = 'z'; ++c)
      System.out.print(c + " ");
    }
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
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
Advertisements

Demonstration


Java Programing Example to Display Alphabets (A to Z) using loop-DevsEnv