0% found this document useful (0 votes)
8 views2 pages

Asterisk Pyramid Pattern Generator

The document describes an assignment to create a pyramid pattern of asterisks based on an integer input `n`. The pyramid should have `n` rows, with each row containing an increasing number of asterisks centered appropriately. It includes example inputs and outputs, function signatures in C++, Python, and Java, and specifies constraints for the input value.

Uploaded by

vampired758
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Asterisk Pyramid Pattern Generator

The document describes an assignment to create a pyramid pattern of asterisks based on an integer input `n`. The pyramid should have `n` rows, with each row containing an increasing number of asterisks centered appropriately. It includes example inputs and outputs, function signatures in C++, Python, and Java, and specifies constraints for the input value.

Uploaded by

vampired758
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment - Pyramid Pattern of Asterisks

----------QUESTION_DESCRIPTION_START----------
You are given an integer `n`. Your task is to print a pyramid pattern of asterisks (`*`) with `n` row
In this pyramid pattern, the first row contains 1 asterisk, the second row contains 3 asterisks, the
third row contains 5 asterisks, and so on. Each row should be centered by placing the appropriate
number of leading spaces before the asterisks so that the pyramid is symmetric.

Example 1:

Input:
3

Output:
*
***
*****

Example 2:

Input:
5

Output:
*
***
*****
*******
*********

Your Task:
- Complete the function printPyramid that takes an integer n as input and prints the pyramid pattern
of height n using asterisks.
- Function Signature:
void printPyramid(int n) (C++)
def print_pyramid(self, n) (Python)
public static void printPyramid(int n) (Java)

Constraints:
- 1 <= n <= 100

Input Format:
- A single integer n on the first line, representing the number of rows of the pyramid.

Output Format:
- The pyramid pattern of asterisks with n rows.

----------QUESTION_DESCRIPTION_END----------

----------SHORT_TEXT_START----------
Pyramid Pattern of Asterisks
----------SHORT_TEXT_END----------

----------QUESTION_LEVEL_START----------
EASY
----------QUESTION_LEVEL_END----------

----------CODE_CONTENT_CPP_START----------
#include <bits/stdc++.h>
using namespace std;

class solution {
public:
void printPyramid(int n) {
// Write your code here...
}
};
----------CODE_CONTENT_CPP_END----------

----------CODE_CONTENT_PYTHON_START----------
class solution:
def print_pyramid(self, n):
# Write your code here...
pass
----------CODE_CONTENT_PYTHON_END----------

----------CODE_CONTENT_JAVA_START----------
import [Link].*;

public class Solution {


public static void printPyramid(int n) {
// Write your code here...
}
}
----------CODE_CONTENT_JAVA_END----------

You might also like