Staircase
Code
#include<bits/stdc++.h>
using namespace std;
//to print the spaces
void space(int x)
{
while(x--)
{
cout<<" ";
}
}
//to print the stars
void star(int y)
{
while(y--)
{
cout<<"#";
}
}
//main function
int main()
{
int n; //Taking the number from user
cin>>n;
for(int i=0;i<n;i++)
{
space(n-i-1);
star(i+1);
cout<<endl;
}
return 0;
}
Staircase Hackerrank Solution in C++
Staircase Hackerrank Solution in Cpp
Staircase Hackerrank Answer
0 Comments