Saturday 30 January 2016

Cpp Program to print a Right angled triangle

This is a simple Cpp Program which prints out a Right angled triangle with respect to the input given.

Right angled triangle pattern program
Download Code
PROGRAM :


#include <iostream>

using namespace std;

int main()
{
    int i, j, n,k;
    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(k=1; k<(i*2); k++)
        {
            cout << k++;
        }
        cout << "\n";
    }
    return 0;
}


Download Code
OUTPUT :
Cpp Program - Right angled triangle pattern