Answer to Question #272640 in C++ for Hamda

Question #272640

Write nested for c++ loops to produce the following output.




×××× / / / / / / / / ××××


××× / / / / / / \ \ ×××


×× / / / / \ \ \ \ ××


× / / \ \ \ \ \ \ ×


\ \ \ \ \ \ \ \

1
Expert's answer
2021-11-30T07:15:29-0500
#include<iostream>

using namespace std;

int main()
{
	const int N=5;
	for(int row=0;row<N;row++)
	{
		for(int i=4-row;i>0;i--)
		{
			cout<<"x";
		}
		for(int i=8-row*2;i>0;i--)
		{
			cout<<"/";
		}
		for(int i=row*2;i>0;i--)
		{
			cout<<"\\";
		}
		for(int i=4-row;i>0;i--)
		{
			cout<<"x";
		}
		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