Alphabet

C Program for print all Alphabet between given range using loops

C Program for print all Alphabet between given range using loops

In this article, we will discuss the concept of C Program for print all Alphabet between given range using loops

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 between given range using loops on C programming language

 

 

Alphabets between the given range

C program to print all Alphabet between the given range

Code to print all Alphabet between given range using for loop

The program displays all the upper case and lower case alphabet letters between given range using for loop in C language

Program 1

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

int main()
{
    char i,ch1,ch2;
    printf("Enter two Alphabet of the range: ");
    scanf("%c %c",&ch1,&ch2);
//store the entered alphabets in variables ch1,ch2

    for(i=ch1; i<=ch2; i++){
     printf("%c ",i);

//display uppercase or lower case Alphabets with space
}
getch();
    return 0;
}

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

Case 1

Enter two Alphabet of the range: i
n
i j k l m n

 

Case 2

Enter two Alphabet of the range: A
H
A B C D E F G H

In the above program, we are using a for loop, this is used to print upper case Alphabet letters or lower case Alphabet letters

Approach

  • In the above program, the user is asked to enter two Alphabet and entered Alphabet is stored in character variable ch1,ch2;
  • In this for loop, it is initialized by i=ch1 and checks the condition of (i<=ch2);
  • If the test expression is true, the program is printed the Alphabets letters between given Alphabets
  • If the test expression is false, the loop is terminated

Code to print all Alphabet between given range using while loop

The program displays all the upper case and lower case alphabet letters between given range using while loop in C language

Program 2

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

int main()
{
    char i,ch1,ch2;
    printf("Enter the two Alphabet of the range: ");
    scanf("%c %c",&ch1,&ch2);
//store the entered alphabets in variables ch1,ch2
    i=ch1;
    while( i<=ch2){
     printf("%c ",i);

//display uppercase or lowercase Alphabets with space
 i++;
}
getch();
    return 0;
}

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

Case 1

Enter two Alphabet of the range: m
z
m n o p q r s t u v w x y z

 

Case 2

Enter two Alphabet of the range:G
T
G H I J K L M N O P Q R S T

In the above program, we are using a while loop, this is used to print upper case Alphabet letters or lower case Alphabet letters

 

Approach

  • In the above program, the user is asked to enter two Alphabet and entered Alphabet is stored in character variable ch1,ch2;
  • In this while loop, it is initialized by i=ch1 and checks the condition of (i<=ch2);
  • If the test expression is true, the program is printed the Alphabets letters between given Alphabets
  • If the test expression is false, the loop is terminated.

Code to print all Alphabet between given range using do-while loop

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

Program 3

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

int main()
{
    char i,ch1,ch2;
    printf("Enter the two Alphabet of the range: ");
    scanf("%c %c",&ch1,&ch2);
//store the entered alphabets in variables ch1,ch2
    i=ch1;
   do{
     printf("%c ",i);

//display uppercase or lowercase Alphabets with space
 i++;
} while( i<=ch2);
getch();
    return 0;
}

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

Case 1

Enter two Alphabet of the range: o
y
o p q r s t u v w x y

 

Case 2

Enter two Alphabet of the range: K
S
K L M N O P Q R S

In the above program, we are using a do-while loop, this is used to print upper case Alphabet letters or lower case Alphabet letters

Approach

  • In the above program, the user is asked to enter two Alphabet and entered Alphabet is stored in character variable ch1,ch2;
  • In this do-while loop, it is initialized by i=ch1 and checks the condition of (i<=ch2);
  • If the test expression is true, the program is printed the Alphabets letters between given Alphabets
  • If the test expression is false, the loop is 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

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

 

 

 

 

Program to Display all Alphabet between given range using loops in Java
C++ Program for print all Alphabet between given range using loops
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

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

2 months ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

2 months ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

10 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

10 months ago