Using Conditional Operator / Ternary Operator determine, whether the character entered through the keyboard is a lower case English alphabet or not.
Also Check:
C Program To Find Special Symbol or Not using Conditional Operator
Related Read:
Relational Operators In C
Logical Operators In C
Ternary Operator / Conditional Operator In C
C Program To Print All ASCII Characters and Code
Page Contents
Expected Output for the Input
User Input:
Enter a character
a
Output:
Character entered is a lowercase English alphabet
Logic To Find Lowercase Alphabet or Not using Conditional Operator
Using Conditional Operator we write the condition, if user entered character is greater than or equal to ASCII Value 97(which corresponds to lowercase character a) and less than or equal to ASCII Value 122(which corresponds to lowercase character z).
If the condition is true, then user entered character is lower case English alphabet, if not, then its not a lowercase English alphabet.
Video Tutorial: C Program To Find Lowercase Alphabet or Not using Conditional Operator
[youtube https://www.youtube.com/watch?v=YM50IowuYhk]
Source Code: C Program To Find Lowercase Alphabet or Not using Conditional Operator
#include < stdio.h > int main() { char ch; printf("Enter a character\n"); scanf("%c", &ch); (ch >= 97 && ch <= 122) ? printf("Character entered is a lowercase English alphabet\n") : printf("Character entered is not a lowercase English alphabet\n"); return 0; }
Output 1:
Enter a character
$
Character entered is not a lowercase English alphabet
Output 2:
Enter a character
A
Character entered is not a lowercase English alphabet
Output 3:
Enter a character
5
Character entered is not a lowercase English alphabet
Output 4:
Enter a character
a
Character entered is a lowercase English alphabet
Output 5:
Enter a character
z
Character entered is a lowercase English alphabet
ASCII Values of Lowercase English Alphabets
ASCII value of a is 97
ASCII value of b is 98
ASCII value of c is 99
ASCII value of d is 100
ASCII value of e is 101
ASCII value of f is 102
ASCII value of g is 103
ASCII value of h is 104
ASCII value of i is 105
ASCII value of j is 106
ASCII value of k is 107
ASCII value of l is 108
ASCII value of m is 109
ASCII value of n is 110
ASCII value of o is 111
ASCII value of p is 112
ASCII value of q is 113
ASCII value of r is 114
ASCII value of s is 115
ASCII value of t is 116
ASCII value of u is 117
ASCII value of v is 118
ASCII value of w is 119
ASCII value of x is 120
ASCII value of y is 121
ASCII value of z is 122
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