Print the given pattern
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;
}
Input
5
Output
*
**
***
****
*****
0 Comments