Answer to Question #17372 in C++ for Yasser
Write a program using two nested loops to draw the following shape
*
***
*****
*******
*****
***
*
1
2012-10-26T11:12:37-0400
#include <cmath>
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
for (int i = 4; i >= -4; i--)
{
int absVal = abs(i);
int count = 1 + (4 - absVal) * 2;
cout << " ";
for (int j = 0; j < absVal; j++)
{
cout << " ";
}
for (int k = 0; k < count; k++)
{
cout << "*";
}
cout << endl;
}
_getch();
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
thank you
Leave a comment