Given some letters and the task is to increment letters like we increment numbers. We will encounter various cases and establish a result.
- Numbers after increment
0 1 2 3...
- Letters after increment
a b c d...
One more interesting thing to notice is that just like numbers start with double-digit after 9 letters do the same after encountering ‘z’
0 1 2 3 ... 9 10 11 12 .. . 99 100 101 ...
a b c d ... z aa ab ac ... zz aaa aab ...
This can be carried out using the simple increment (++) operator just like in numbers. The only point of difference being decrement (–) operator doesn’t work the same in letters as it does in numbers.
Example 1: Program to increment various letters and print it.
b ab aab aaab
Example 2: Program to print all letters between ‘a’ to ‘y’.
Output: This example is looped till ‘y’ because if the limit in for is set until it reaches ‘z’, the required result is different. The loop executes until it encounters ‘z’
Note: Decrement doesn’t work on letters
Program 3: Program to show that decrement doesn’t work on letters.
The following program produces an infinite loop of letter 'd'
- How to validate if input in input field has lowercase letters only using express-validator ?
- How to validate if input in input field has uppercase letters only using express-validator?
- How to create an HTML button that acts like a link?
- How to Create Background Like TV Noise in a Canvas ?
- How to change a span to look like a pre with CSS?
- How to achieve <fieldset> like effect without using <fieldset> tag ?
- Why does sizeof(x++) not increment x in C?
- CSS | counter-increment Property
- How to format numbers by prepending 0 to single-digit numbers?
- PHP | gmp_add() for adding large numbers
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- Fermat's Factorization method for large numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.