A
asif929
I am trying to write a program which creates four triangles. The
program begins with prompting a user " Enter the size of triangles",
number from 1 to N is the size of four triangles For Example if we
enter 4, the size of four triangles are 4 rows.
In addition, I am also writing a program which i started and failed in
giving the right size of traingles. I will appreciate if somebody can
help.
*
* *
* * *
* * * *
* * * *
* * *
* *
*
* * * *
* * *
* *
*
*
* *
* * *
* * * *
I have also tried to create this program but i couldn't be able to
correct the formating of "*".
#include <iostream>
using namespace std;
int main()
{
cout << "Enter a character:>";
int n;
cin >> n;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= row; column++ )
cout << ' ';
for ( int column = 0; column < (3 - row); column++ )
cout << " * ";
cout << " "<< endl;
cout << endl;
}
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= (3 - row); column++ )
cout << " * ";
cout << " ";
cout << endl;
}
cout<<endl;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= row; column++ )
cout << " * ";
cout << " ";
cout << endl;
}
cout<<endl;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column < row; column++ )
cout << ' ';
for ( int column = 0; column <= (3 - row);
column++ )
cout << " * ";
cout << endl;
}
return 0;
program begins with prompting a user " Enter the size of triangles",
number from 1 to N is the size of four triangles For Example if we
enter 4, the size of four triangles are 4 rows.
In addition, I am also writing a program which i started and failed in
giving the right size of traingles. I will appreciate if somebody can
help.
*
* *
* * *
* * * *
* * * *
* * *
* *
*
* * * *
* * *
* *
*
*
* *
* * *
* * * *
I have also tried to create this program but i couldn't be able to
correct the formating of "*".
#include <iostream>
using namespace std;
int main()
{
cout << "Enter a character:>";
int n;
cin >> n;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= row; column++ )
cout << ' ';
for ( int column = 0; column < (3 - row); column++ )
cout << " * ";
cout << " "<< endl;
cout << endl;
}
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= (3 - row); column++ )
cout << " * ";
cout << " ";
cout << endl;
}
cout<<endl;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column <= row; column++ )
cout << " * ";
cout << " ";
cout << endl;
}
cout<<endl;
for ( int row = 0; row < n; row++ )
{
for ( int column = 0; column < row; column++ )
cout << ' ';
for ( int column = 0; column <= (3 - row);
column++ )
cout << " * ";
cout << endl;
}
return 0;