Answer to Question #329405 in C++ for Haji San

Question #329405

Use nested while loop to print this shape





+----------+



| ^^ |



| ^ ^ |



| ^ ^ |



| ^^ |



| ^ ^ |



| ^ ^ |



+----------+



|v v|



| v v |



| vv |



|v v|



| v v |



| vv |



+----------+

1
Expert's answer
2022-04-16T06:47:48-0400
#include<iostream>


using namespace std;


int main()
{
	for (int i = 0; i < 10; i++)
	{
		if (i == 0 || i == 9)cout << "+";
		else
			cout << "-";
	}
	cout << endl;
	for (int i = 0; i < 6; i++)
	{
		if (i %3==0)cout << "| ^^ |"<<endl;
		else
			cout << "| ^ ^ |"<<endl;
	}
	for (int i = 0; i < 10; i++)
	{
		if (i == 0 || i == 9)cout << "+";
		else
			cout << "-";
	}
	cout << endl;
	for (int i = 0; i < 6; i++)
	{
		if (i % 3 == 0)cout << "|v v|" << endl;
		else if (i % 3 == 1)
			cout << "| v v |" << endl;
		else
			cout << "| vv |" << endl;
	}
	for (int i = 0; i < 10; i++)
	{
		if (i == 0 || i == 9)cout << "+";
		else
			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
APPROVED BY CLIENTS