RSS

PROGRAM TO PRINT THE LOWER TRIANGLE ELEMENTS (USING POINTERS)

21 Nov

// THIS PROGRAM PRINTS LOWER TRIANGLE ELEMENTS OF MATRIX (USING POINTERS)

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int size;
cout<<“\nENTER THE SIZE OF THE MATRIX\n”;
cin>>size;
int **arr = new int *[size];

for(int i =0; i<size; i++)
arr[i] = new int [size];

cout<<“\nINPUT THE MATRIX \n”;

for(i =0; i<size; i++)
for(int j= 0; j<size; j++)
cin>>*(*(arr+i) + j);

cout<<“\nTHE LOWER TRIANGLE ELEMENTS OF THE MATRIX ARE \n”;

for(i = 0; i<size; i++)
{
for(j = 0; j<size; j++)
{
if(i>j)
cout<<*(*(arr + i) + j)<<‘ ‘;
else
cout<<‘ ‘<<‘ ‘;
}
cout<<‘\n’;
}

getch();
}

Advertisements
 
Leave a comment

Posted by on November 21, 2015 in Matrices, Pointers and Arrays

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

 
%d bloggers like this: