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 😉

About Pankaj

Pankaj Prakash is the founder, editor and blogger at Codeforwin. He loves to learn new techs and write programming articles especially for beginners. He works at Vasudhaika Software Sols as a Software Design Engineer and manages Codeforwin. In short Pankaj is Web developer, Blogger, Learner, Tech and Music lover.

Follow on: Facebook | Twitter | Google | or

Comments and discussion
Have a doubt, write here. I will help my best.
Before commenting you must escape your source code before commenting. Paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>