C program to print all alphabets from a to z using while loop

Write a C program to print all alphabets from a to z using while loop. How to display alphabets from a to z using while loop in C programming.

Example

Input

Output

Alphabets: a, b, c, d, e, ... , z

Required knowledge

Basic C programming, While loop

Read more - Program to print all alphabets from a to z using for loop

Program to print alphabets

/**
 * C program to print all alphabets using while loop
 */

#include <stdio.h>

int main()
{
    char ch = 'a';

    printf("Alphabets from a - z are: \n");
    while(ch<='z')
    {
        printf("%c\n", ch);
        ch++;
    }

    return 0;
}

Note: If you want to print alphabets in uppercase you just need to replace the lower-case assignment and conditional checks statements in loop which is ch='A' and ch<='Z'.

Characters in C are internally represented as an integer value known as ASCII value.
ASCII value of a = 97
ASCII value of z = 122
Hence we can also write the above program using ASCII values.

Program to display alphabets using ASCII value

/**
 * C program to display all alphabets using while loop
 */

#include <stdio.h>

int main()
{
    int ch = 97;

    printf("Alphabets from a - z are: \n");
    while(ch<=122)
    {
        printf("%c\n", ch);
        ch++;
    }

    return 0;
}

Output

Alphabets from a - z are:
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

Happy coding 😉

Write your doubts or suggestion. I will try my best to help. You must escape source code before commenting. To format your source code paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>