Sep 21, 2014 at 5:57am UTC
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
Sep 21, 2014 at 6:40am UTC
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 Sep 21, 2014 at 6:40am UTC
Sep 21, 2014 at 6:51am UTC
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 Sep 21, 2014 at 6:52am UTC
Sep 21, 2014 at 7:23am UTC
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'.