Astericks Program Code – Lab #5
Change ROWS variable to the number of rows you want to print.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> #include <iomanip> // for the setw() manipulator using namespace std; int main() { int ROWS = 4; // Yeah in capitals, just to make it look cool! for (int x=1; x < ROWS + 1; x++) { cout << setw (ROWS + 1 - x); for (int i=1; i <= x * 2 - 1; i++) cout << "*"; cout << endl; } for (x=ROWS-1; x > 0; x--) { cout << setw (ROWS + 1 - x); for (int i=1; i <= x * 2 - 1; i++) cout << "*"; cout << endl; } return 0; // This comment is self explanatory... no need to explain :) } |


aby yaar class me nahi bta sakta tha??
ye class se hi tu post kia tha maine yar…