program to print upper & lower triangle of a matrix

Answer Posted / arka bandyopadhyay

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[5][5],i,j;
clrscr();
printf("\n");
//upper triangle matrix
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
arr[i][j]=(i+j);
}
}
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(j<4-i)
{printf(" ");
}
else printf("%d",arr[i][j]);
}
printf("\n");
}
printf("\n");
//lower triangle matrix
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(j>=4-i)
{printf(" ");
}
else printf("%d",arr[i][j]);
}
printf("\n");
}

getch();
}

Is This Answer Correct ?    6 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of void pointer?

779


What are file streams?

764


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

1821


Give basis knowledge of web designing ...

1764


What is the use of clrscr?

777


What are the types of data files?

914


What is bin sh c?

773


Why is it important to memset a variable, immediately after allocating memory to it ?

1759


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

2871


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

834


What is meant by type specifiers?

873


What's the difference between constant char *p and char * constant p?

881


Explain how do you search data in a data file using random access method?

891


What are qualifiers in c?

766


Is it possible to have a function as a parameter in another function?

821