Random Pattern

08:26 0 Comments A+ a-

Problem:
Write a program that takes size "n" from user and displays the following pattern.
Sample Run 1:
Enter Size: 5
* * * * *
* * * *
* * *
* *

*
Solution:
# include <iostream>
using namespace std;
int main()
{
int size;
int j;
int temp;
cout<<"Please enter the size of pattern : ";
cin>>size;
temp=size;
for(int i=0;i<size;i++)
{
j=1;
while (j<=temp)
{
cout<<"*"<<" ";
j++;
}
cout<<endl;
temp--;

}

return 0;

}