Print the below 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;
cin>>n;
for(int i=n;i>=0;i--)
{
space(n-i);
star(i);
cout<<endl;
}
return 0;
}
Input
5
Output
*****
****
***
**
*
0 Comments