HI!!FRIENDS
c program to find minimum number in each row and maximum number in each column and common elements in them.
EX:
n=2
matrix is :
5 5
7 6
minimum number in each row is
5 6
maximum number in each row is
7 6
The common in both row and column is 6.
PROGRAM:
#include<stdio.h>
int main()
{
int n,i,j;
printf("enter the row no and column no");
scanf("%d",&n);
int a[n][n],min[n],max[n];
printf("enter the matrix");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("the matrix is\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
for(j=0;j<n;j++)
{
max[j]=a[0][j];
for(i=0;i<n;i++)
{
if(a[i][j]>max[j])
{
max[j]=a[i][j];
}
}
}
for(i=0;i<n;i++)
{
min[i]=a[i][0];
for(j=0;j<n;j++)
{
if(a[i][j]<min[i])
{
min[i]=a[i][j];
}
}
}
printf("\nminimum number in each row\n");
for(i=0; i<n; i++)
{
printf("%d ",min[i]);
}
printf("\n");
printf("maximum numbers in each column\n");
for(i=0; i<n; i++)
{
printf("%d ",max[i]);
}
printf("\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(min[i]==max[j])
{
printf("The common in both row and column is %d\t", min[i]);
}
}
}
return 0;
}
you can copy and compile by clicking this
HAAPY CODING!!...
copyright© to jagadeesh
Post a Comment