How can I write a single for loop running from a to z and A to Z in C?

Viewed 31691

I want to combine both the for loops into single for loop. How can i do that?

I want to loop through a to z, and A to Z, like so:

char ch;
for (ch = 'A' ; ch <= 'Z' ; ch++ )
{ 
}
for (ch = 'a' ; ch <= 'z' ; ch++ )
{
}

but using a single loop.

13 Answers
Related