How do i make the astrix do this?... I know I have to add spaces somewhere Im just not sure where... i have the first two triangles down .. the third and fourth one im struggling with.. and also this is according to what the user puts in .. so for example this is for 5.
#include <iostream>
usingnamespace std;
int main() {
int num;
do
{
cout << "Enter a number between 1 and 15: " << endl;
cin >> num;
if (num > 15 || num < 1)
{
cout << "Error! The number must be between 1 and 15." << endl;
}
}
while (num > 15 || num < 1);
for(int pattern = 0; pattern < 2; pattern++)
{
for (int i = num; i > 0; i--)
{
for (int j = 0; j < i; j++)
{
cout << "*";
}
cout << endl;
}
}
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int num;
do
{
cout << "Enter a number between 1 and 15: " << endl;
cin >> num;
if (num > 15 || num < 1)
{
cout << "Error! The number must be between 1 and 15." << endl;
}
}
while (num > 15 || num < 1);
for (int i = num; i > 0; i-- )
{
for (int s = 0; s < num - i; s++)
{
cout << " ";
}
for (int j = 0; j < i; j++)
{
cout << "*";
}
cout << endl;
}
return 0;
}