Tuesday, July 28, 2009

C++ HELP, 2 loops?

A


BB


CCC


DDDD


EEEEE


FFFFFF





i have to write a program at school that will display the above letters, it has to have two loops in it, does anyone have code that can do that?? im using Dev-C++


i know its something to d with incrementing, but i cant get it to work

C++ HELP, 2 loops?
char ch = 'A'; // establish your starting letter


for(int i = 1; i %26lt;= 6; ++i){ // do something six times


for(int j = 0; j %26lt;= i; ++j){ // do something i times


cout %26lt;%26lt; ch; // output i instances of the letter


}


++ch; // advance to the next letter


cout %26lt;%26lt; endl; // go to beginning of next line


}
Reply:What do you need two loops for... talk to me at NolesToGiants@gmail.com





let me see the requirements.
Reply:People don't generally have code like this laying around, but here are two hints to help you get over the hump.





1. One of the two loops is inside the other.


2. The big thing is converting the number of the line you're printing into both a number of characters and an upper-case alphabetic character.





Hope that helps.


No comments:

Post a Comment