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 'named constructor idiom'?
What are the types of type specifiers?
What is difference between static and global variable in c?
FILE PROGRAMMING
What is difference between stdio h and conio h?
Why & is used in scanf in c?
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
What is the difference between āgā and āgā in C?
What are enumerated types?
Why static is used in c?
difference between Low, Middle, High Level languages in c ?
what is the difference between 123 and 0123 in c?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What are reserved words?
What is 02d in c?