Printing Right Triangles Next to each other using asterisks

using [include <iostream>]
i cannot make a Right Triangles Next to each other using asterisks.i want an output just like from below.please help me...

*.......................**********........**********......................*
**.....................*********............*********....................**
***...................********................********..................***
****.................*******....................*******................****
*****...............******........................******..............*****
******.............*****............................*****............******
*******...........****................................****..........*******
********.........***....................................***........********
*********.......**........................................**......*********
**********.....*............................................*....**********

MY syntax i was not able to make an output just like the above..without that dots.


#include<iostream>
using namespace std;
int main()
{
//First Triangle



for (int i = 0; i <= 10; i++) //this prints stars as rows

{

for (int j = 0; j < 10; j++) //this prints stars as columns

{

if (j == i)

{

cout << " *";

}

else

{

cout << " ";

}

}

cout << endl;

}


//Second triangle

for (int i = 0; i <= 10; i++) //this prints stars as rows

{

for (int j = 0; j < 1; j++) //this prints stars as columns

{

if (j == i)

{

cout << " ";

}

else

{

cout << "*";

}

}

}





//Third Triangle

for (int i = 0; i <= 10; i++) //this prints stars as rows

{

for (int j = 0; j < 1; j++) //this prints stars as columns

{

if (j == i)

{

cout << " ";

}

else

{

cout << "*";

}

}

}






//Fourth Triangle

for (int i = 0; i <= 10; i++) //this prints stars as rows

{

for (int j = 0; j < 1; j++) //this prints stars as columns

{

if (j == i)

{

cout << "*";

}

else

{

cout << " ";

}

}

}


system("pause");
return 1;
}
i dont know what to do .please help me..
Last edited on
Here, i solved your problem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
for (int i = 1; i <= 10; i++) //this prints stars as rows
{
    for (int j = 0; j <= 10; j++) //this prints stars as columns
    {
        if(i == j )
            cout<<" ";
        cout << "*";
    }
    cout<<" ";
    for(int k = 10; k >= 0; k--)
    {
        cout<<"*";
        if(k == i)
            cout<<" ";
    }
    cout<<"\n";
}
@mj verdadero
Please run my code may be i solved your issue...
and please use code tags that will be more readable to people..
I think you are after this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
int k = 11;

    for (int i = 0; i < 10; i++)
    {
        for(int x = 0; x <= i; x++)
        {
            cout << "*";
        }
        for(int x = 0; x < k; x++)
        {
            cout <<" ";
        }
        for(int x = 0; x < k; x++)
        {
            cout <<"*";
        }
        for(int x = 0; x <= i; x++)
        {
            cout << " ";
        }
        for(int x = 0; x <= i; x++)
        {
            cout << " ";
        }
        for(int x = 0; x < k; x++)
        {
            cout <<"*";
        }
        for(int x = 0; x < k; x++)
        {
            cout <<" ";
        }
        for(int x = 0; x <= i; x++)
        {
            cout << "*";
        }
        k--;
        cout << endl;
    }
Topic archived. No new replies allowed.