Question: Staircase Hacker Rank Problem Solution Using C++. Problem Statement Your teacher has given you the task to draw the structure of a staircase. Being an
Staircase Hacker Rank Problem Solution Using C++.
Problem Statement
Your teacher has given you the task to draw the structure of a staircase. Being an expert programmer, you decided to make a program for the same. You are given the height of the staircase. You need to print a staircase as shown in the example.
Input Format
You are given an integer N depicting the height of the staircase.
Constraints 1?N?100
Output Format
Draw a staircase of height N in the format given below.
For example:
# ## ### #### ##### ######
Staircase of height 6, note that last line has 0 spaces before it.
Sample Input
6
Sample Output
# ## ### #### ##### ######
TAG: C++,Implementation , Simple Program , Hacker Rank. I am wondering how you would write the pseudocode of the following source code. Please write the pseudocode of the source code and also explain the reasoning behind both the pseudocode and the source code. Solution:
#include#include #include #include #include using namespace std; /* * * Prosen Ghosh * American International University - Bangladesh (AIUB) * */ int main() { int n,sp,w = 1,k; cin >> n; k = n-1; for(int i = 0; i < n; i++){ sp = k; for(int j = 0; j < sp; j++)cout << " "; for(int m = 0; m < w; m++)cout << "#"; cout << endl; k--; w++; } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
