Friday, November 13, 2020

Matrix C programming ....in which diagonal ele == 0, rowcol == 1.

 #include<stdio.h>

#include<conio.h>

void main()

{

    int i,j,mat[10][10],row,col;

    printf("Enter the no of row and column :");

    scanf("%d%d",&row,&col);

    for(i=0;i<row;i++)

    {

        for(j=0;j<col;j++)

        {

            if(i==j)

               mat[i][j]=0;

            else if(i<j)

               mat[i][j]=-1;

            else

               mat[i][j]=1;

        } 

    }

  for(i=0;i<row;i++)

   {

      printf("\n");

      for(j=0;j<col;j++)

      {

          printf("%d\t",mat[i][j]);

      }

   }

}

OUTPUT :




2 comments:

Stack program - push,pop,peep,display,change,length,middle_element....... in c language.

#include<stdio.h> #include<stdlib.h> #include<conio.h> #define MAX 10 int stack[MAX],top = -1; void push(); int pop(); int...