Answer to Question #102821 in C++ for harshavardhan singh

Question #102821
Write a program that reads in a number and prints out the letter T using '*' characters with each line in the T having width n. Further, the length of the horizontal bar should be 3n, and that of the vertical bar 2n. Thus for n=3 your program should print

*********
*********
*********
***
***
***
***
***
***
1
Expert's answer
2020-02-12T09:37:49-0500
#include <iostream>


int main()
{
	int n;
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3 * n; ++j) std::cout << '*';
		std::cout << "\n";
	}
		
	for (int i = 0; i < 2 * n; ++i)
	{
		for (int j = 0; j < n; ++j) std::cout << ' ';
		for (int j = 0; j < n; ++j) std::cout << '*';
		std::cout << "\n";
	}
}

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