Print till end of alphabet – CSKC
Sign In

Search

Code Learning #CPP#7609    siteicon   siteicon  

Print till end of alphabet

Source Code

TC++ #7609

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

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.


Share

Created: 1-Mar-2026 16:43 | Updated: 19-Apr-2026 18:50|