19. Fill upper triangle with 1, lower triangle with
-1 and diagonal elements
with 0.
#include<stdio.h>
int main(){
int a[10][10],i,j,row_size,col_size;
clrscr();
printf("\nEnter the row
size:\n");
scanf("%d",&row_size);
printf("\nEnter the column
size:\n");
scanf("%d",&col_size);
printf("\nThe lower diagonal
elements of the matrix is\n");
for(i=0;i<row_size;i++)
{
printf("\n");
for(j=0;j<col_size;j++)
{
if(i>j)
printf("-1\t");
if(i<j)
printf("1\t");
if(i==j)
printf("0\t");
}
return 0;
}
No comments:
Post a Comment