65 767
Assignments Done
99,4%
Successfully Done
In October 2018

Answer to Question #17372 in C++ for Yasser

Question #17372
Write a program using two nested loops to draw the following shape
*
***
*****
*******
*****
***
*
Expert's answer
#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!

Comments

Assignment Expert
29.10.12, 15:26

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

Yasser
26.10.12, 20:07

thank you

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions