Alphabet

Java program to print all upper case and lower case Alphabets

Java program to print all upper case and lower case Alphabets

In this article, we will discuss the concept of Java program to print all upper case and lower case Alphabets

In this post, we are going to learn how to display all the upper case and lower case Alphabets using loops in Java language

Display A to Z Alphabets

Code to print all upper case and lower case

Code to print all  Alphabets using for loop

The program displays all the upper case and lower case alphabets letters from a to z using for loop in Java language

Program 1

public class Display_Alphabets{
public static void main(String args[]){
char ch;//char variable declaration
//Printing upper case Alphabets
System.out.println("Uppercase Alphabets are: \n");
for(ch='A'; ch<='Z'; ch++){
System.out.print(ch+" ");
//display uppercase Alphabets with space
}
System.out.print("\n");//move to next line

//Printing lower case Alphabets
System.out.println("Lowercase Alphabets are: \n");
for(ch='a'; ch<='z'; ch++){
System.out.print(ch+" ");
//display lowercase Alphabets with space
}

}

}

When the above code is executed, it produces the following result

Output 1

In the above program, we are using two for loops, one is used to print upper case letters and another to print lower case letters

 

Code to print all  Alphabets using while loop

The program displays all the upper case and lower case alphabets letters from a to z using while loop in Java language

Program 2

 

public class Display_Alphabets1{
public static void main(String args[]){
char ch;//char variable declaration
//Printing upper case Alphabets
System.out.println("Uppercase Alphabets are: \n");
ch='A';
while(ch<='Z'){
System.out.print(ch+" ");
//display uppercase Alphabets with space
ch++;
}
System.out.print("\n");//move to next line

//Printing lower case Alphabets
System.out.println("Lowercase Alphabets are: \n");
ch='a';
while(ch<='z'){
System.out.print(ch+" ");
//display lowercase Alphabets with space
ch++;
}

}

}

When the above code is executed, it produces the following result

Output 2

In the above program, we are using two while loops, one is used for printing upper case letters and another to print lower case letters

 

Code to print all Alphabets using do-while loop

The program displays all the upper case and lower case alphabets letters from a to z using do-while loop in Java language

Program 3

 

public class Display_Alphabets1{
public static void main(String args[]){
char ch;//char variable declaration
//Printing upper case Alphabets
System.out.println("Uppercase Alphabets are: \n");
ch='A';
do{
System.out.print(ch+" ");
//display uppercase Alphabets with space
ch++;
}while(ch<='Z');
System.out.print("\n");//move to next line

//Printing lower case Alphabets
System.out.println("Lowercase Alphabets are: \n");
ch='a';
do{
System.out.print(ch+" ");
//display lowercase Alphabets with space
ch++;
}while(ch<='z');

}

}

When the above code is executed, it produces the following result

Output 3

In the above program, we are using two do-while loops, one is used to print upper case letters and another is used for printing lower case letters

 

Approach

  • We will declare a counter variable “ch” of the loops (for loop, while loop and do-while loop) and initialize it by “a“(for print lower case) or “A” (for print upper case);
  • The program checks the given condition(ch<=”z” (lower case) or ch<=”Z”(Upper case) if the condition is true, alphabets will be printed
  • if the condition is false – loops will be terminated

 

Suggested for you

Suggested for you

while loop in Java language

do-while loop in Java language

for loop in Java language

for loop in C++ language

while loop in C++ language

do-while loop in C++ language

 

Similar post

Java program to print all upper case and lower case Alphabets

C++ program to print all upper case and lower case Alphabets

C program to print all upper case and lower case Alphabets

 

Java code to print all upper case and lower case Alphabets between the given range

C++ code to print all upper case and lower case Alphabets between the given range

C code to print all upper case and lower case Alphabets between the given range

 

 

C++ program to print all upper case and lower case Alphabets
C program to print all upper case and lower case Alphabets
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 hours ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago