Alphabets in lowercase and uppercase can be printed using two methods, first is using ASCII values and second is to directly print values from ‘A’ to ‘Z’ using loops.
Below are the implementation of both methods:
Program to display all alphabets from A to Z in uppercase and lowercase using ASCII values:
- ASCII value of uppercase alphabets – 65 to 90.
- ASCII value of lowercase alphabets – 97 to 122.
Below is the implementation:
C++
#include <iostream>
using namespace std;
void lowercaseAlphabets()
{
for ( int c = 97; c <= 122; ++c)
cout << char (c) << " " ;
cout << endl;
}
void uppercaseAlphabets()
{
for ( int c = 65; c <= 90; ++c)
cout << char (c) << " " ;
cout << endl;
}
int main()
{
cout << "Uppercase Alphabets" << endl;
uppercaseAlphabets();
cout << "Lowercase Alphabets " << endl;
lowercaseAlphabets();
return 0;
}
|
C
#include <stdio.h>
void lowercaseAlphabets()
{
for ( int c = 97; c <= 122; ++c)
printf ( "%c " , c);
printf ( "\n" );
}
void uppercaseAlphabets()
{
for ( int c = 65; c <= 90; ++c)
printf ( "%c " , c);
printf ( "\n" );
}
int main()
{
printf ( "Uppercase Alphabets\n" );
uppercaseAlphabets();
printf ( "Lowercase Alphabets\n" );
lowercaseAlphabets();
return 0;
}
|
Java
class Alpha {
private int ch;
void uppercaseAlphabets()
{
for ( char c = 65 ; c <= 90 ; ++c)
System.out.print( " " + c);
System.out.print( "\n" );
}
void lowercaseAlphabets()
{
for ( char c = 97 ; c <= 122 ; ++c)
System.out.print( " " + c);
System.out.print( "\n" );
}
public static void main(String[] args)
{
int ch;
System.out.println( "Uppercase Alphabets" );
Alpha ob = new Alpha();
ob.uppercaseAlphabets();
System.out.println( "Lowercase Alphabets " );
ob.lowercaseAlphabets();
}
}
|
Javascript
function lowercaseAlphabets() {
for (let c = 97; c <= 122; ++c) {
process.stdout.write(String.fromCharCode(c) + " " );
}
console.log();
}
function uppercaseAlphabets() {
for (let c = 65; c <= 90; ++c) {
process.stdout.write(String.fromCharCode(c) + " " );
}
console.log();
}
console.log( "Uppercase Alphabets" );
uppercaseAlphabets();
console.log( "Lowercase Alphabets" );
lowercaseAlphabets();
|
PHP
<?php
function lowercaseAlphabets()
{
for ( $c = 97; $c <= 122; ++ $c )
echo chr ( $c ). " " ;
echo "\n" ;
}
function uppercaseAlphabets()
{
for ( $c = 65; $c <= 90; ++ $c )
echo chr ( $c ). " " ;
echo "\n" ;
}
echo "Uppercase Alphabets\n" ;
uppercaseAlphabets();
echo "Lowercase Alphabets \n" ;
lowercaseAlphabets();
?>
|
Python3
def lowercaseAlphabets():
for c in range ( 97 , 123 ):
print ( chr (c), end = " " );
print ("");
def uppercaseAlphabets():
for c in range ( 65 , 91 ):
print ( chr (c), end = " " );
print ("");
print ( "Uppercase Alphabets" );
uppercaseAlphabets();
print ( "Lowercase Alphabets " );
lowercaseAlphabets();
|
Output
Uppercase Alphabets
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
Lowercase Alphabets
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
Program to display all alphabets from A to Z in uppercase and lowercase using alphabets directly
- For lowercase alphabets – Run a loop from ‘a’ to ‘z’
- For uppercase characters – Run a loop from ‘A’ to ‘Z’
Below is the implementation:
C++
#include <iostream>
using namespace std;
void lowercaseAlphabets()
{
for ( char c = 'a' ; c <= 'z' ; ++c)
cout << c << " " ;
cout << endl;
}
void uppercaseAlphabets()
{
for ( char c = 'A' ; c <= 'Z' ; ++c)
cout << c << " " ;
cout << endl;
}
int main()
{
cout << "Uppercase Alphabets" << endl;
uppercaseAlphabets();
cout << "Lowercase Alphabets " << endl;
lowercaseAlphabets();
return 0;
}
|
C
#include <stdio.h>
void lowercaseAlphabets()
{
for ( char c = 'a' ; c <= 'z' ; ++c)
printf ( "%c " , c);
printf ( "\n" );
}
void uppercaseAlphabets()
{
for ( char c = 'A' ; c <= 'Z' ; ++c)
printf ( "%c " , c);
printf ( "\n" );
}
int main()
{
printf ( "Uppercase Alphabets\n" );
uppercaseAlphabets();
printf ( "Lowercase Alphabets\n" );
lowercaseAlphabets();
return 0;
}
|
Java
class Alpha {
private int ch;
void uppercaseAlphabets()
{
for ( char c = 'A' ; c <= 'Z' ; ++c)
System.out.print( " " + c);
System.out.print( "\n" );
}
void lowercaseAlphabets()
{
for ( char c = 'a' ; c <= 'z' ; ++c)
System.out.print( " " + c);
System.out.print( "\n" );
}
public static void main(String[] args)
{
System.out.println( "Uppercase Alphabets" );
Alpha ob = new Alpha();
ob.uppercaseAlphabets();
System.out.println( "Lowercase Alphabets " );
ob.lowercaseAlphabets();
}
}
|
Javascript
class Alpha {
uppercaseAlphabets() {
for (let c = 65; c <= 90; c++) {
console.log( " " + String.fromCharCode(c));
}
console.log( "\n" );
}
lowercaseAlphabets() {
for (let c = 97; c <= 122; c++) {
console.log( " " + String.fromCharCode(c));
}
console.log( "\n" );
}
static main() {
console.log( "Uppercase Alphabets" );
let ob = new Alpha();
ob.uppercaseAlphabets();
console.log( "Lowercase Alphabets" );
ob.lowercaseAlphabets();
}
}
Alpha.main();
|
PHP
<?php
function uppercaseAlphabets()
{
for ( $c = ord( 'A' ); $c <= ord( 'Z' ); ++ $c )
echo ( " " . chr ( $c ));
echo ( "\n" );
}
function lowercaseAlphabets()
{
for ( $c = ord( 'a' ); $c <= ord( 'z' ); ++ $c )
echo ( " " . chr ( $c ));
echo ( "\n" );
}
echo ( "Uppercase Alphabets" );
uppercaseAlphabets();
echo "Lowercase Alphabets " ;
lowercaseAlphabets();
|
Python3
import string
def lowercase_alphabets():
for i in string.ascii_lowercase:
print (i,end = " " )
print ()
def uppercase_alphabets():
for j in string.ascii_uppercase:
print (j, end = " " )
print ( "Uppercase Alphabets are : " )
uppercase_alphabets()
print ( "\nLowercase Alphabets are : " )
lowercase_alphabets()
|
Output
Uppercase Alphabets
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
Lowercase Alphabets
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
These programs print all alphabets in uppercase and lowercase continuously.
Contact Us