C > Beginners Lab Assignments
Program to pick & display the largest element of an input matrix
Program to pick & display the largest element of an input matrix #include
#include
#include
#define MAXROWS 30 #define MAXCOLS 30 void largest(int a[][MAXCOLS],int nrows,int ncols); void readinput(int a[][MAXCOLS],int m,int n); void main() { int nrows,ncols; int a[MAXROWS][MAXCOLS]; clrscr(); printf("How many rows in the matrix? "); scanf("%d",&nrows); printf("How many columns in the matrix? "); scanf("%d",&ncols); printf(" Table "); readinput(a,nrows,ncols); largest(a,nrows,ncols); getch(); } void readinput(int a[][MAXCOLS],int m,int n) { int row,col; for (row=0;row
largest) largest=a[i][j]; } } printf(" The largest element of the matrix is %d",largest); return; }
C Codes
Beginners
C on Unix
Code Snippets
Data Structures
File Operations
Games Graphics
Gnu-Linux
Hardware
Mathematics
Miscellaneous
Small Programs
Sorting