Answer to Question #285263 in C++ for Jeanelle

Question #285263

Using the looping statement. Create a program that will display the following:

  1. -------------------- *
  2. ------------------- ***
  3. ------------------ ****
  4. ------------------ ****
  5. ------------------- ***
  6. ---------------------*
1
Expert's answer
2022-01-07T01:51:02-0500
using namespace std;


/*
	Using the looping statement. Create a program that will display the following:


	-------------------- *
	------------------- ***
	------------------ ****
	------------------ ****
	------------------- ***
	---------------------*
*/


int main()
{
	int x,y,n,r;
	int N=25;
	for(n=1;n<=3;n=n+1)
	{
		for(r=0;r<N-(n+2);r++) cout<<"-";
		cout<<" ";
		for(r=0;r<(2*n-1);r++) cout<<"*";
		cout<<endl;
	}
	for(n=3;n>=1;n=n-1)
	{
		for(r=0;r<N-(n+2);r++) cout<<"-";
		cout<<" ";
		for(r=0;r<(2*n-1);r++) cout<<"*";
		cout<<endl;
	}
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog