This is a simple Cpp Program which prints out a triangle with respect to the input given , here the obtained triangle is filled with numbers.
Download Code
Triangle pattern with numbers |
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; }
OUTPUT :
Cpp Program - Triangle with numbers |