How do I print something like the one in the description using a loop. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I print something like the one in the description using a loop.

# ## ### #### ##### ###### #######

20th Dec 2020, 7:00 PM
Lekhanooe Albert Kekele
Lekhanooe Albert Kekele - avatar
6 Answers
+ 2
and if you want more or less than 7 int n; cin>>n; for(int i=1;n>=i;i++) { for (int j = 1; i>=j; j++) cout << "#"; cout<<endl; }
20th Dec 2020, 10:06 PM
titan
+ 1
for(int i=0;i<7;i++) { for(int j=0;j<i+1;j++) cout<<"#"; cout<<"/n"; } I think this should work
20th Dec 2020, 7:05 PM
Temporary
+ 1
https://code.sololearn.com/cbk5Bx6ZNOLd/?ref=app This is the link of where I tried
20th Dec 2020, 7:09 PM
Lekhanooe Albert Kekele
Lekhanooe Albert Kekele - avatar
0
Using a single loop:- string a; for(int i = 0; cout << a << endl, i < 7 ; i++) a.insert(a.size(), 1, '#');
20th Dec 2020, 7:30 PM
rodwynnejones
rodwynnejones - avatar
0
Troll version: for(int i=0;i==0;i++) cout<<"#/n##/n###/n####/n#####/n######/n#######";
20th Dec 2020, 8:06 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
Thank you good people I can see where I was wrong.
21st Dec 2020, 3:47 AM
Lekhanooe Albert Kekele
Lekhanooe Albert Kekele - avatar