123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to pick & display the largest element of an input matrix.

--------------------------------------------------------------------------------



#include <stdio.h>
#include <conio.h>
#include <math.h>
#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<BR>);
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<m;++row)
{
printf("
Enter data for row no. %2d<BR>,row+1);
for (col=0;col<n;++col)
scanf("%d",&a[row][col]);
}
printf(" TABLE 1");
for (row=0;row<m;++row)
{
printf("
");
for (col=0;col<n;++col)
printf("%d%c",a[row][col],' ');
}
return;
}


void largest(int a[][MAXCOLS],int m,int n)
{
int i,j,largest;
largest = a[0][0];
for (i=0;i<m;++i)
{
for (j=0;j<n;++j)
{
if (a[i][j]>largest)
largest=a[i][j];
}
}
printf("
The largest element of the matrix is %d",largest);
return;
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG