top of page

Minimum & Maximum Element In Matrix

Writer's picture: Code CrazeCode Craze


#include <stdio.h>

void main() {

int a[100][100];

int r, c;

int i, j;

int max;

int min;

printf("\nEnter rows : ");

scanf("%d", &r);

printf("\nEnter columns : ");

scanf("%d", &c);

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

{

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

{

printf("\nEnter %d, %d element : ",i, j);

scanf("%d",&a[i][j]);

}

}

printf("\n----Matrix----\n");

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

{

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

{

printf("%d ",a[i][j]);

}

printf("\n");

}

max=a[0][0];

printf("\n----Maximum----\n");

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

{

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

{

if(max<a[i][j])

{

max=a[i][j];

}

}

}

printf("Maximum : %d", max);

min=a[0][0];

printf("\n\n----Minimum----\n");

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

{

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

{

if(min>a[i][j])

{

min=a[i][j];

}

}

}

printf("\n Minimum : %d", min);

}

1 view0 comments

Recent Posts

See All

Stack Using Queue

A stack can be implemented using two queues in C. The basic idea is to use one queue for enqueue operations and another for dequeue...

Kommentare


bottom of page