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 a nested loop?
What is calloc() function?
What is difference between union All statement and Union?
What is the difference between a free-standing and a hosted environment?
Write a program to swap two numbers without using the third variable?
What is line in c preprocessor?
What are the different types of objects used in c?
Why do we need arrays in c?
What is s in c?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
a c code by using memory allocation for add ,multiply of sprase matrixes
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
Explain the concept and use of type void.
What is the size of a union variable?
what is the height of tree if leaf node is at level 3. please explain