Print till end of alphabet
Source Code
|
|
Run Output
Code Understanding
This program prints all letters from the entered alphabet up to āZā (uppercase) or āzā (lowercase).
⢠char ch; stores the input alphabet.
⢠int n = ch; converts the character to its ASCII value.
⢠if(n >= 65 && n = 97 && n <= 122) ā checks if it is lowercase (a-z).
⢠lc = 90 – n + 1 (uppercase) or lc = 122 – n + 1 (lowercase) calculates how many letters to print until Z/z.
⢠for(int i = 0; i < lc; i++) cout << (char)n++; prints each letter by converting the ASCII value back to a character and incrementing it.
⢠If the input is not an alphabet, the program shows a message and exits.
Created: 1-Mar-2026 16:43 | Updated: 19-Apr-2026 18:50|
