C++ program which takes input a character and check it whether entered character is capital letter, small letter, Digit or Special character
All characters like small letters, capital letters, digits or special character have ASCII codes when a key is pressed from keyboard there is always an ASCII value behind it like if small letter 'a' is pressed its ASCII is 97 if capital letter 'A' is pressed its ASCII value is 65 if a number digit '0' is pressed its ASCII value is 48.
ASCII value ranges
0 - 9 48 - 57
A - Z 65 - 90
a - z 97 - 122
Special Characters 0-47, 58-64, 91-96, 123-127
On the basis of ASCII values and using operators like and operator (&&) or Operator (||) we can differentiate the letters.
Concept Used
If you enter more that one character program will show the result on the basis of first charater
Sample Input:
This Program helps to understand the operators like OR operator(||) how if else works, and ASCII values of characters
All characters like small letters, capital letters, digits or special character have ASCII codes when a key is pressed from keyboard there is always an ASCII value behind it like if small letter 'a' is pressed its ASCII is 97 if capital letter 'A' is pressed its ASCII value is 65 if a number digit '0' is pressed its ASCII value is 48.
ASCII value ranges
0 - 9 48 - 57
A - Z 65 - 90
a - z 97 - 122
Special Characters 0-47, 58-64, 91-96, 123-127
On the basis of ASCII values and using operators like and operator (&&) or Operator (||) we can differentiate the letters.
Concept Used
- ASCII values of charaters
- And (&&) Operator
- OR (||) Operator
- if else Statement
If you enter more that one character program will show the result on the basis of first charater
#include<iostream>
|
Sample Input:
C++ program to check the entered character is a capital letter, a small letter, a digit or a special character |
This Program helps to understand the operators like OR operator(||) how if else works, and ASCII values of characters
0 comments:
Post a Comment