So this teacher assigned us to write 2 code that one of them prints out a triangle-like pattern, with character '*'!And he told us to do so, using the loop for.I managed to do it with the following code:
#include <iostream>
using namespace std;
int main()
{
int i,j;
for(i=1;i<11;i++)
{
cout<<endl;
for(j=1;i>j;j++)
{
cout<<'*';
}
}
for(i=10;i>0;i--)
{
cout<<endl;
for(j=1;i>j;j++)
{
cout<<'*';
}
}
cin.get();
return 0;
}
And it ran flawless. But my mind got frozen when I saw the second one! He's said to write a code that prints out a pattern like this:
*
***
*****
*******
*****
***
*
I have no idea how to even start writing it! Can someone help?