How to print in c ++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to print in c ++

Hello, so I have to input some char, for example " *" and cout it n times in each row, while every row has that charachter -n. e.g. I enter 5 and output is ***** **** *** ** * I don't have a code, and you don't have to give me the entire code, I just need some ideas how to do it using loop. Ty

4th Nov 2020, 10:20 AM
Dr. Alien
Dr. Alien - avatar
2 Answers
+ 5
Here's what you need to proceed:- Starting from top, i th line have (n-i) "*"s in it.{ n = number of lines }
4th Nov 2020, 10:23 AM
Arsenic
Arsenic - avatar
+ 4
Run two for loops ,outer one will run n times and inner one will run (n - outer loop current iteration value) ,so it will be like n-0,n-1,n-2,.....,n-(n-1)
4th Nov 2020, 10:27 AM
Abhay
Abhay - avatar