TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: ELIJAH RICHARD
from: DARIN MCBRIDE
date: 1998-04-19 19:29:00
subject: Nested loop

 ER> A
 ER> AB
 ER> ABC
 ER> ABCD
 ER> ABCDE
 ER> This is what I have:
 ER> void main() {
     ^^^^
This wouldn't be from a Schildt book, would it?
 ER>         int count, Ascii;
 ER>         for(count = 1; count <= 5; count++) {
 ER>                 for(Ascii = 65; Ascii ........
 ER> This is where I got stuck. I don't know what the test 
 ER> expression should be for the second one. Also, I really 
 ER> don't know if I should use the ++ or --.
What is 65?  ('A' ... in ASCII systems, but not all of us use ASCII... )
You want to go from 'A' to the count'th letter, right?  Use this knowledge to 
build your for loop.
                           Translation
Start: at 'A'              letter = 'A'
End:   at 'A' + count - 1  letter < 'A' + count
Step:  one at a time       ++letter
So we have:
int main()
{
  int  count;
  char letter;
  for (count = 1; count <= 5; ++count)
    for (letter = 'A'; letter < 'A' + count; ++letter)
      /* I assume you know what comes here... */
  return 0; /* success return code */
}
 ER> Can any of you elite help me here? Please?
How about some of us non-elite?  :-)
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.