07:51 0 Comments A+ a-

Problem:
Write a program that takes size from user a displays the following pattern:

Sample Run 1:
Enter Size: 5
Output:
1
1 2
1 2 3
1 2 3 4

1 2 3 4 5
Solution Code:
# include <iostream>
using namespace std;
int main()
{
int size;
int j;
int b=1;
cout<<"Please enter the size of pattern : ";
cin>>size;
for(int i=0;i<size;i++)
{
j=1;
while (j<=b)
{
cout<<j<<" ";
j++;
}
cout<<endl;
b++;

}

return 0;

}