Diagonal Matrix
I have written the code for the following problem. the code is working fine but i am not able to remove the space after the end of each row. can someone please help? An Upper triangular matrix is a square matrix (where the number of rows and columns are equal) where all the elements below the diagonal are zero. For example, the following is an upper triangular matrix with the number of rows and columns equal to 3. 1 2 3 0 5 6 0 0 9 Write a program to convert a square matrix into an upper triangular matrix. Input Format: The first line of the input contains an integer number n which represents the number of rows and the number of columns. From the second line, take n lines input with each line containing n integer elements. Elements are separated by space. Output format: Print the elements of the matrix with each row in a new line and each element separated by a space. Example 1: Input: 3 1 2 3 4 5 6 7 8 9 Output: 1 2 3 0 5 6 0 0 9 https://code.sololearn.com/cqRGGLYJOD1