Answer to Question #160960 in C++ for Rohit Rawat

Question #160960

Write a program that reads in a number and prints out the letter L using '*' characters

with each line in the L having width n. Further, the length of the horizontal bar should be

4n, and that of the vertical bar (i.e. not including the portion overlapping with the

horizontal bar) should be 3n. Thus for n=3 your program should print


***

***

***

***

***

***

***

***

***

************

************

************

OutputTest Case 1
*
*
*
****
Test Case 2
**
**
**
**
**
**
********
********
Test Case 3
****
****
****
****
****
****
****
****
****
****
****
****
****************
****************
****************
****************
1
Expert's answer
2021-02-03T11:18:18-0500
#include <iostream>
using namespace std;
int main()
{
	int l;
	cout << "Enter number: ";
	cin >> l;
	for (int i = 0; i < 3 * l; i++)
	{
		for (int j = 0; j < l; j++)
		{
			cout << "*";
		}
		cout << endl;
	}
	for (int i = 0; i < l; i++)
	{
		for (int j = 0; j < 4*l; j++)
		{
			cout << "*";
		}
		cout << endl;
	}
	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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog