-->

program to know a matrix is identity or not

// program to know a matrix is identity or not
//to know a matrix is identity or not
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a[5][5],order,i,j,first=0,second=0;
printf("enter order\n");
scanf("%d",&order);
printf("enter matrix elements\n");
for(i=0;i<order;i++)
  {
    for(j=0;j<order;j++)
      {
       scanf("%d",&a[i][j]);
      }
  }
printf("the matrix is\n");
for(i=0;i<order;i++)
  {
    for(j=0;j<order;j++)
      {
       printf("%d",a[i][j]);
      }
    printf("\n");

  }
 for(i=0;i<order;i++)
  {
    for(j=0;j<order;j++)
      {
       if(i==j)
       {
first=first+1;
}
else
{
second=second+a[i][j];
}

  }
  }

  if(first==order && second==0)
  {
  printf("it is identity matrix\n");
  }
  else
  {
  printf("it is not");
  }

  getch();
  }

program to understand strcmp(), libraray function

//program to understand strcmp(), libraray function
//strcmp() function
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char first[50],sec[50];
int k;
gets(first);
gets(sec);
k=strcmp(first,sec);
printf("k=%d",k);
if(k==0)
  {
    printf("both are same");
    }
else if(k>0)
  {
  printf("first string =%s has more value\n",first);
  }
  else if(k<0)
  {
  printf("second string =%s has more value\n",sec);
  }
  getch();
  }

program to get hcf and lcm of two numbers

//program to get hcf and lcm of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,n1,lcm,hcf;
printf("enter numbrs\n");
scanf("%d%d",&a,&b);
if(a>b)
{
n=a;
}
else
{
n=b;
}
for(n1=n;n1>=1;n1--)
    {
    if(a%n1==0 && b%n1==0)
     {
     hcf=n1;
     break;
     }
}
printf("hcf=%d",hcf);
printf("lcm=%d",(a*b)/hcf);
getch();
}

program to multiply two matrices of order mxn

// program to multiply two matrices of order 'mxn'
#include <stdio.h>
#include<conio.h>
void main()
{
    int A[3][3], B[3][3], C[3][3];
    int row, col, i, sum;

    /*
     * Reads elements in first matrix from user
     */
    printf("Enter elements in matrix A of size 2x2: \n");
    for(row=0; row<2; row++)
    {
for(col=0; col<2; col++)
{
   scanf("%d", &A[row][col]);
}
    }

    /*
     * Reads elements in second matrix from user
     */
    printf("\nEnter elements in matrix B of size 2x2: \n");
    for(row=0; row<2; row++)
    {
for(col=0; col<2; col++)
{
   scanf("%d", &B[row][col]);
}
    }

    /*
     * Multiplies both matrices A*B
     */
    for(row=0; row<2; row++)
    {
for(col=0; col<2; col++)
{
   sum = 0;
   /*
    * Multiplies row of first matrix to column of second matrix
    * And stores the sum of product of elements in sum.
    */
   for(i=0; i<2; i++)
   {
sum += A[row][i] * B[i][col];
   }

   C[row][col] = sum;
}
    }

    /*
     * Prints the product of matrices
     */
    printf("\nProduct of Matrix A * B = \n");
    for(row=0; row<2; row++)
    {
for(col=0; col<2; col++)
{
   printf("%d ", C[row][col]);
}
printf("\n");
    }
getch();;
}