C Program To Print Uppercase Alphabet(A-Z) using While loop

In this video tutorial we show you how to write C program to print all the upper case alphabets(A-Z) using simple while loop.

Related Read:
while loop in C programming

Note: In C programming language, every character variable holds an ASCII value rather than the character itself. You can check ASCII value of all the characters here: C Program To Print All ASCII Characters and Code

Note:
ASCII value range of upper case alphabets:
ASCII value of A is 65.
ASCII value of B is 66.
ASCII value of C is 67.
and so on till Z ..
ASCII value of Z is 90.

Source Code: C Program To Print Uppercase Alphabet(A-Z) using While loop

#include < stdio.h >

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

    printf("Uppercase English Alphabets:\n");
    while(ch <= 'Z')
    {
        printf("%c ", ch);
        ch++;
    }
    printf("\n\n");

    return 0;
}

Output:
Uppercase English 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

Logic To Print Uppercase Alphabet(A-Z) using While loop

Each alphabet has it’s own(unique) ASCII value. So we initialize the character variable to A, and then using while loop we iterate until our character variable is equal to Z. C program checks with the characters underlying ASCII values. Inside while loop we increment the value of character variable by one for each iteration and also print the character present in it.

Video Tutorial: C Program To Print Uppercase Alphabet(A-Z) using While loop


[youtube https://www.youtube.com/watch?v=NTNsLcMeYRE]

YouTube Link: https://www.youtube.com/watch?v=NTNsLcMeYRE [Watch the Video In Full Screen.]

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Check Whether a Character is an Alphabet or Not

Lets write a C program to check if user input character is an alphabet or not.

Related Read:
Relational Operators In C
Logical Operators In C

Note: In C programming language, every character variable holds an ASCII value rather than the character itself. You can check ASCII value of all the characters here: C Program To Print All ASCII Characters and Code

Also watch video tutorial: C Program to Print ASCII Value of a Character

Note: ASCII value range of lower case alphabets:
ASCII value of a is 97.
ASCII value of b is 98.
ASCII value of c is 99.
and so on till z ..
ASCII value of z is 122.

ASCII value range of upper case alphabets:
ASCII value of A is 65.
ASCII value of B is 66.
ASCII value of C is 67.
and so on till z ..
ASCII value of Z is 90.

Source Code: C Program To Check Whether a Character is an Alphabet or Not

#include < stdio.h >

int main()
{
    char c;

    printf("Enter a character\n");
    scanf("%c", &c);

    if( (c >= 'a' && c <= 'z') ||
        (c >= 'A' && c <= 'Z') )
    {
        printf("%c is an alphabet\n", c);
    }
    else
    {
        printf("%c is not an alphabet\n", c);
    }

    return 0;
}

Output 1:
Enter a character
5
5 is not an alphabet

Output 2:
Enter a character
a
a is an alphabet

Output 3:
Enter a character
$
$ is not an alphabet

Output 4:
Enter a character
S
S is an alphabet

Output 5:
Enter a character
#
# is not an alphabet

Logic To Check Whether a Character is an Alphabet or Not

We accept the character from user as input. We check if the user entered character is greater than or equal to a and less than or equal to z OR the user entered character is greater than or equal to A and less than or equal to Z. If these conditions are met, then user entered character is an alphabet or else its not.

Video Tutorial: C Program To Check Whether a Character is an Alphabet or Not


[youtube https://www.youtube.com/watch?v=uY3d6SXBBNE]

YouTube Link: https://www.youtube.com/watch?v=uY3d6SXBBNE [Watch the Video In Full Screen.]

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert