Problem :
plz give me the solution of the following matrix in c
1 1 1 1 0
1 1 1 0 -1
1 1 0 -1 -1
1 0 -1 -1 -1
0 -1 -1 -1 -1
Solution :
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j=0,no=0;
clrscr();
printf("\nPlease Enter The number : - ");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\n");
for(j=0;j<no;j++)
{
if(i==(no-j-1))
printf("0");
else if(i<(no-j-1))
printf("1");
else
printf("-1");
}
}
getch();
}
plz give me the solution of the following matrix in c
1 1 1 1 0
1 1 1 0 -1
1 1 0 -1 -1
1 0 -1 -1 -1
0 -1 -1 -1 -1
Solution :
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,j=0,no=0;
clrscr();
printf("\nPlease Enter The number : - ");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\n");
for(j=0;j<no;j++)
{
if(i==(no-j-1))
printf("0");
else if(i<(no-j-1))
printf("1");
else
printf("-1");
}
}
getch();
}
0 comments:
Post a Comment