Answer to Question #324596 in C++ for Secret Agent

Question #324596

Pyramid Schemes

by CodeChum Admin

They said pyramids were created by aliens, so if you can make a pyramid you might be able to qualify as an alien.


Instructions:

  1. In the code editor, you are provided with a main() function that asks the user for an integer input n, and passes this value to the function call of the generatePattern() function.
  2. Your task is to implement this generatePattern() function which has the following description:
  3. Return type - void
  4. Function name - generatePattern
  5. Parameters - 1 integer n
  6. Description - this function prints a triangular pattern of letter T's based on the value of n. For more information, refer to the output in the test cases
  7. DO NOT EDIT ANYTHING IN THE MAIN

Input


1. Integer n

Output


Enter·n:·4
T
TT
TTT
TTTT




1
Expert's answer
2022-04-08T16:06:20-0400
#include <iostream>
using namespace std;


void generatePatern(int n) {
    for (int i=0; i<n; i++) {
        for (int j=0; j<=i; j++) {
            cout <<'T';
        }
        cout << endl;
    }
}


int main() {
    int n;
    cout << "Enter n: ";
    cin >> n;
    generatePatern(n);


    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