i mangaged to get the code and this is c program
program
#include<stdio.h>
#include<conio.h>
void main()
{
int r,c,i,j,a[20][20];
clrscr();
printf("\n neter the rows and colums of matrix respectively");
scanf("%d%d",&r,&c);
printf("\n enter the terms of matrix");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<c;j++)
{
printf("%3d",a[i][j]);
}
}
if(r==c);
{
printf("\n the lower traingular matrix is");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if(i!=j)
{
if(i<j)
{
printf("%3d",a[i][j]);
}
}
}
printf("\n the upper traingular matrix is");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if(i!=j)
{
if(i>j)
{
printf("%3d",a[i][j]);
}
}
}
}
}
}
getch();
}
output
enter the rows and columns 3 3
enter terms 1 2 3 4 5 6 7 8 9
1 2 3
4 5 6
7 8 9
the lower triangular matrix is 2 3 // i need to get lower traingular matrix as 2 3 6
the upper traingular matrix is 4 7 8
PLEASE HELP
#include <stdio.h>
#include <conio.h>
void main()
{
int r,c,i,j,a[20][20];
clrscr();
printf("\n neter the rows and colums of matrix respectively");
scanf("%d%d",&r,&c);
printf("\n enter the terms of matrix");
for (i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<c;j++)
{
printf("%3d",a[i][j]);
}
}
if (r==c);
{
printf("\n the lower traingular matrix is");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if(i!=j)
{
if(i<j)
{
printf("%3d",a[i][j]);
}
}
}
printf("\n the upper traingular matrix is");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if(i!=j)
{
if(i>j)
{
printf("%3d",a[i][j]);
}
}
}
}
}
}
getch();
}
Now it becomes clear. At line 32 is the start of a for loop. The closing brace for that loop is at line 59. Nested within that loop is another for loop, starting at line 46 and ending at line 58.
I think all that is needed here is to disentangle these two loops. Oh and also remove the unwanted semicolon at line 29.