Print the below Pattern
* * * * *
* * * *
* * *
* *
*
Code
#include<bits/stdc++.h>
using namespace std;
// Function to print space
void space(int x)
{
while(x>0)
{
x--;
cout<<" ";
}
}
// Function to print star
void star(int y)
{
while(y--)
{
cout<<"* ";
}
}
// main function
int main()
{
int n;
cin>>n;
int temp = 0;
for(int i=n;i>0;i--)
{
space(temp);
star(i);
cout<<endl;
temp++;
}
return 0;
}
Input
5
Output
* * * * *
* * * *
* * *
* *
*
0 Comments