Tuesday, 26 January 2016

Cpp Program to print palindrome triangle

This is a Cpp Program which prints thee palindrome triangle based on the input given.

Here , check each row elements , you can see a palindrome sequence.
Palindrome triangle

Download Code

PROGRAM :

#include <iostream>

using namespace std;

int main()
{
    int i,j,n;
    cout << "Enter number of lines[height of triangle] : \t";
    cin >> n;
    for(i=1; i<=n; i++)
    {
        for(j=i; j<n; j++)
            cout << " ";
        for(j=1; j<=i; j++)
            cout << j;
        for(j=i-1; j>=1; j--)
            cout << j;
        cout << "\n";
    }
    return 0;
}

OUTPUT :

Cpp program - Palindrome triangle

Download Code