#include<iostream> #include<cstdlib> using namespace std; int main() { int i=0, j=0, NUM=3; for(i=-NUM; i<=NUM; i++) { for(j=-NUM; j<=NUM; j++) { if( abs(i)+abs(j)<=NUM) // Change this condition { cout<<"*"; } else { cout<<" ";} } cout<<endl; } return 0; }The above code will prints-
*
***
*****
*******
*****
***
*
Wait I haven’t done yet. You can have fun with it. Just change the ‘ if ‘ condition. You will get new design . Wanna see???. Lets take a look-
if( abs(i)*abs(j)<= NUM)
prints-
***
***
*******
*******
*******
***
***
***
*******
*******
*******
***
***
if( abs(i)*abs(j)<= NUM)
*
* *
* *
* *
* *
* *
*
* *
* *
* *
* *
* *
*
|
* *
* *
* *
*
* *
* *
* *
* *
* *
*
* *
* *
* *
|
|
*
*
*
*******
*
*
*
*
*
*******
*
*
*
|
|
*******
*****
***
*
***
*****
*******
*****
***
*
***
*****
*******
|
|
* *
** **
*** ***
*******
*** ***
** **
* *
** **
*** ***
*******
*** ***
** **
* *
That’s it. Just change the condition and have fun with it. ENJOY !
what do i need to print 5 rows of 10 astericks
ReplyDeletePlay Real Money Slots in NJ | JammyHub
ReplyDeleteFree Slots Sites — 고양 출장마사지 Play real money 여주 출장마사지 online slots in NJ. 아산 출장샵 Check 과천 출장안마 our list of top sites to play Real Money slots and get a top bonus in December 광주광역 출장샵 2021.