How to print alphabets using any loop?

Output should be something like this:
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
You can use a for loop for that.

Read the for loop->http://www.cplusplus.com/doc/tutorial/control/

For loops look like this
1
2
3
for(int i=0;i<n;i++) { 
  //body of the loop
}

Hint: You can increment the value of 'A' to get other letters.

Try to write something on your own and post it here, I will help you then.
Last edited on
there are many wys to do that
for ( int n = 97; static_cast<char>n < 123; n++)

or

for( char letter = 'a' ; static_cast<int>letter <= 'z'; letter++)

etc.etc.etc.
try loook at this one http://www.cplusplus.com/doc/ascii/
Last edited on
for( char letter = 'a' ; static_cast<int>letter <= 'z'; letter++) that would be static_cast<int>(letter) but any case there is no need to cast it. You can simply do for(char letter = 'a'; letter <= 'z'; ++letter) or with upper case you would start with 'A' and end with 'Z'.
but any case there is no need to cast it

thats why i said there many ways to do that and i gave him the toughest one lol
Topic archived. No new replies allowed.