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
What is the purpose of void pointer?
What are file streams?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
Give basis knowledge of web designing ...
What is the use of clrscr?
What are the types of data files?
What is bin sh c?
Why is it important to memset a variable, immediately after allocating memory to it ?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
What is meant by type specifiers?
What's the difference between constant char *p and char * constant p?
Explain how do you search data in a data file using random access method?
What are qualifiers in c?
Is it possible to have a function as a parameter in another function?