+ 1

How to print this pattern?

* *** ***** ******* *********

9th Jul 2018, 6:48 AM
Sathish M
4 Answers
+ 4
#include <iostream> using namespace std; int main() { int a = 16; int k; for(int i = 1; i < 2 * a; i+= 2){ for(k = 0;k < a - i / 2; k++) cout << ' '; for(k = 0; k < i; k++) cout << "*"; cout << endl; } return 0; }
9th Jul 2018, 1:40 PM
Mert Yazıcı
Mert Yazıcı - avatar
9th Jul 2018, 6:57 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
An way is: from 1 to 9 by step 2 as N print (N/2)-times 'space' print N-times '*' print (N/2)-times 'space'
9th Jul 2018, 6:55 AM
KrOW
KrOW - avatar