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
Explain what is wrong with this program statement? Void = 10;
In which header file is the null macro defined?
Which programming language is best for getting job 2020?
Function calling procedures? and their differences? Why should one go for Call by Reference?
Why isnt there a numbered, multi-level break statement to break out
How many main () function we can have in a project?
Write a program to use switch statement.
Explain how to reverse singly link list.
the question is that what you have been doing all these periods (one year gap)
Explain the difference between #include "..." And #include <...> In c?
What is the size of a union variable?
What is difference between scanf and gets?
Why we use conio h in c?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
What are the different types of endless loops?