Alphabet

C Program for Display Alphabets using ASCII value

C Program for Display Alphabets using ASCII value

In this article, we will discuss the concept of C Program for Display Alphabets using ASCII value

In this post, we are going to learn how to display all the upper case(A to Z) and lower case (a to z) Alphabets using ASCII in C programming language

Display Alphabets using ASCII
  • ASCII value of upper case Alphabets letters are between 65 – 90
  • ASCII value of lower case Alphabets letters are between 97 – 122

Program for display Alphabets using for loop

The program displays all the upper case and lower case alphabet letters between a to z using for loop in C language

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;//char variable declaration
//Printing upper case Alphabets
printf("Uppercase Alphabets are: \n");
for(ch=65; ch<=90; ch++){
printf("%c",ch);
printf(" ");
//display uppercase Alphabets with space
}
printf("\n");//move to next line

//Printing lower case Alphabets
printf("\nLowercase Alphabets are: \n");
for(ch=97; ch<=122; ch++){
printf("%c",ch);
printf(" ");
//display lowercase Alphabets with space
}

    //printf("Hello world!\n");
    getch();
    return 0;
}

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

Display Alphabets

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

 

Approach

  • We will declare a counter variable “ch” of the for loop and it is initialized by “65”(for print upper case) or “97” (for print lower case);
  • The program checks the given condition(ch<=90 (upper case) or ch<=122(lower case) if the condition is true, alphabets will be printed
  • if the condition is false – loops will be terminated

 

Program for display Alphabets using while loop

The program displays all the upper case and lower case alphabet letters between a to z using while loop in C language

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;//char variable declaration
//Printing upper case Alphabets
printf("Uppercase Alphabets are: \n");
ch=65;
while(ch<=90){
printf("%c",ch);
printf(" ");
//display uppercase Alphabets with space
 ch++;
}
printf("\n");//move to next line

//Printing lower case Alphabets
printf("\nLowercase Alphabets are: \n");
ch=97;
while(ch<=122){
printf("%c",ch);
printf(" ");
//display lowercase Alphabets with space
 ch++;
}

    //printf("Hello world!\n");
    getch();
    return 0;
}

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

Display Alphabets

 

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

 

Approach

  • We will declare a counter variable “ch” of the while loop and it is initialized by “65”(for print upper case) or “97” (for print lower case);
  • The program checks the given condition(ch<=90 (upper case) or ch<=122(lower case) if the condition is true, alphabets will be printed
  • if the condition is false – loops will be terminated

 

Program for print Alphabets using do-while loop

The program displays all the upper case and lower case alphabet letters between a to z using the do-while loop in C language

Program 3

 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;//char variable declaration
//Printing upper case Alphabets
printf("Uppercase Alphabets are: \n");
ch=65;
do{
printf("%c",ch);
printf(" ");
//display uppercase Alphabets with space
 ch++;
}while(ch<=90);
printf("\n");//move to next line

//Printing lower case Alphabets
printf("\nLowercase Alphabets are: \n");
ch=97;
do{
printf("%c",ch);
printf(" ");
//display lowercase Alphabets with space
 ch++;
}while(ch<=122);

    //printf("Hello world!\n");
    getch();
    return 0;
}

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

Display Alphabets

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

 

Approach

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

 

Suggested for you

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

 

C Program for Display Alphabets in Java using ASCII value

Java Program for Display Alphabets in Java using ASCII value

C++ Program for Display Alphabets in Java using ASCII value

Python Program for Display Alphabets in Java using ASCII value

 

Program for Display Alphabets in Java using ASCII value
C++ Program for Display Alphabets using ASCII value
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

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

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago