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 'named constructor idiom'?

645


What are the types of type specifiers?

625


What is difference between static and global variable in c?

541


FILE PROGRAMMING

1781


What is difference between stdio h and conio h?

891






Why & is used in scanf in c?

629


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1466


What is the difference between ā€˜gā€™ and ā€œgā€ in C?

2619


What are enumerated types?

657


Why static is used in c?

627


difference between Low, Middle, High Level languages in c ?

1636


what is the difference between 123 and 0123 in c?

729


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

1633


What are reserved words?

662


What is 02d in c?

640