 <p>Use modulus operator <code>%</code>, this makes sure character stays in range between A to Z. </p> <pre><code>char c = 'A' + shift % 26; </code></pre> <p>You can shift letters to the right, then once letter reaches Z, the next letter will be A</p> <pre><code>int main() { int row, col; for (row = 0; row &lt; 26; row++) { for (col = 0; col &lt; 26; col++) { char c = 'A' + (row + col) % 26; printf("%c ", c); } printf("\n"); } printf("\n"); return 0; } </code></pre>