English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

2007-11-15 09:55:42 · 3 answers · asked by d_nortontaylor 2 in Computers & Internet Programming & Design

3 answers

char ch = 'A'; // establish your starting letter
for(int i = 1; i <= 6; ++i){ // do something six times
for(int j = 0; j <= i; ++j){ // do something i times
cout << ch; // output i instances of the letter
}
++ch; // advance to the next letter
cout << endl; // go to beginning of next line
}

2007-11-15 10:55:30 · answer #1 · answered by jgoulden 7 · 0 0

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.

2007-11-15 18:06:30 · answer #2 · answered by The Phlebob 7 · 1 0

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

let me see the requirements.

2007-11-15 18:05:31 · answer #3 · answered by Licursi 2 · 0 1

fedest.com, questions and answers