Answer to Question #321004 in C for jay

Question #321004

1. Pyramid Schemes

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-03-30T07:39:53-0400






#include <stdio.h>
#include <stdlib.h>


void generatePattern(int n){
	int i,j;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= i; j++) {
			printf("T");
		}
		printf("\n");
	}
}


int main(){
	
	int number;
	printf("Enter n: ");
	scanf("%d",&number);


	generatePattern(number);
	getchar();
	getchar();
	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