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

Question #325796

 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-08T03:47:52-0400
#include <iostream>
using namespace std;

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

  generatePattern(n);
    return 0;
}

void  generatePattern(int n){
    int i,j;
    for(i=1;i<=n;i++){
        for(j=0;j<i;j++)
         cout<<'T';
    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