Answer to Question #102721 in C++ for AKASH KUMAR SINHA

Question #102721
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-10T03:51:10-0500
#include <iostream>
using namespace std;

int main()
{
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
        cout << string(n * 3, '*') << endl;
    for (int i = 0; i < 2 * n; i++)
        cout << string(n, ' ') << string(n, '*') << 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
APPROVED BY CLIENTS