How can i print the lower and upper triangles of matrix
Please guide me in writing the code.
i don't know even how to start writing the code.
Please help.

>>i don't know even how to start writing the code
Start here

#include <iostream>
using std::cout;
using std::cin;
int main()
{
// put your code here
}

First, you need to declare the matrix. How many dimensions does it have (2, 3, 4, 5, ...) What dimensions does it have? What type (int, short, double, char*, or something else?)

>>i don't know even how to start writing the code
Start here

#include <iostream>
using std::cout;
using std::cin;
int main()
{
// put your code here
}

First, you need to declare the matrix. How many dimensions does it have (2, 3, 4, 5, ...) What dimensions does it have? What type (int, short, double, char*, or something else?)

i want to know that after accepting values from user what i have to do to print the triangles.

Oh, well in that case, how are you storing the matrix? Probably an array of numbers, I would guess.

If you are just starting, might be easiest to use a 2D array; declare an mxn array of integers (or whatever data type you need to hold, where m = number of rows, n = number of columns). If you are dealing strictly with square matrices, then m = n.

For the upper triangular one:
Simply loop through and print out the first n entries of row 1, (n-1) entries of row 2, (n-2) entries of row 3, ... , (n - (m-1)) = (n - m + 1) entries of row m.

If you are a little heavier on the math side, you could also try to implement it using a 1D array, (after all, a rectangular 2D array is really just a 1D array in disguise).

Ummm, the lower triangular one is very similar, if you can see the pattern then you should be on track to solving it now..