Java program to display alphabets (A to Z) using loop
Write a java program to display alphabets (A to Z) using loop
In this program, we can loop through A to Z using for loop because they are stored as ASCII characters in java.
This java program iterates the ASCII code from 65 to 90, representing the alphabets A to Z and print them.
With a little modification you can display lowercase alphabets to simply replace the A with a and Z with z. In this case, internally your loop through 97 to 122.
- Program:
class Main {
public static void main(String[] args) {
char n;
for(n = 'A'; n <= 'Z'; ++n) // For lowercase: for(n = 'a'; n <= 'b'; ++n)
System.out.print(n + " ");
}
}
- Output:
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
- Visit:
Java program to swap two numbers Here
Java program to check whether a given number is even or odd Here
Java program to check whether an alphabet is vowel or consonant Here
Java program to find the largest among three numbers Here
Java program to find all roots of a quadratic equation Here
Java program to check leap year Here
Write a java program to multiply two floating point numbers Here
Java program to check whether a number is positive or negative Here
Java program to check whether a character is alphabet or not Here
Java program to calculate the sum of natural numbers Here
Java program to find factorial of a number Here
Java program to generate multiplication table Here
Write a java program to display Fibonacci series Here
Write a java program to find GCD of two numbers Here
Write a java program to find LCM of two numbers Here
0 comments