answer this plz
write a program to print the following pattern if the number of line is 1 .
*
if the number of line is 2
*
* *
if lines are 4
*
* *
* * *
* * * * *
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int main()
{
int objects = 0;
int number = 0;
cout << "Enter a number: ";
cin >> number;
cout << endl;
while(number != 0)
{
++objects;
for(int i = 0; i < objects; ++i)
cout << '*';
cout << endl;
--number;
}
return 0;
}
|
Topic archived. No new replies allowed.