0

How do i print the following number pattern(Triangular pattern)

............1
.........1 2 1
......1 2 3 2 1
...1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by firstPerson
0
#include<iostream>

int main(){
    std::cout << "........1\n......1 2 1\n....1 2 3 2 1\n..1 2 3 4 3 2 1\n1 2 3 4 5 4 3 2 1";
}

or you could try something with loops.

But seriously: You should start by writing these problems on paper. Then step by step write down what your program needs to do. If you've written down some ideas, come back here and we'll give advice.

Is the numbers of lines to be printed a fixed number?

0
#include<iostream>

int main(){
    std::cout << "........1\n......1 2 1\n....1 2 3 2 1\n..1 2 3 4 3 2 1\n1 2 3 4 5 4 3 2 1";
}

or you could try something with loops.

But seriously: You should start by writing these problems on paper. Then step by step write down what your program needs to do. If you've written down some ideas, come back here and we'll give advice.

Is the numbers of lines to be printed a fixed number?

yes

0

You might want to try a more general approach, where the user
gets to input the number of rows for the tree.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.