Dynamic allocation of matrix

This C++ example demonstrates the dynamic allocation of memory for lower triangular or symmetric matrix


//============================================================================
// Name        : triangMatrix.cpp
// Author      : chd
// Version     :
// Copyright   : Your copyright notice
// Description : Allocating memory dynamically for a symmetric or lower triangular matrix
//============================================================================

#include <iostream>
using namespace std;

int main() {

	//m is for # of rows
	int m;
	cout<<"Enter m diamension of symmetric-triangular matrix";
	cin>>m;
	//allocating memory for rows
	double** triangMatrix=new double*[m];
	//allocating memory for collumns
	for (int i = 0; i < m; ++i) {
		triangMatrix[i]=new double [i+1];
	}

	//accessing the matrix, e.x assign values to elements
	for (int i = 0; i < m; ++i) {

		for (int j = 0; j <= i; ++j) {

			triangMatrix[i][j]=1;

		}

	}

	//printing in console
	for (int i = 0; i < m; ++i) {
		cout<<endl;
		for (int j = 0; j <= i; ++j) {

			cout<<"|"<<triangMatrix[i][j]<<"|";

		}

	}

	
	//deleting
	for (int i = 0; i < m; ++i) {
		delete[] triangMatrix;
	}



	return 0;
}