#include<stdio.h>
int max (int [][5]);
int min (int [][5]);
int main()
{
int c[2][5];
int i,j;
float sum=0;
printf("Please enter elements of 2-D array of 2 rows and 5 columns:");
for(i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
scanf("%d",&c[i][j]);
sum=sum+c[i][j];
}
}
printf("Your elemnts are\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
printf("%8d\n",c[i][j]);
}
}
printf("\nSum of your array is : %.2f \n",sum);
printf("Maximum Number of your array is : %d \n",max (c));
printf("Minimum Number of your array is : %d \n",min (c));
printf("Average Number of your array is : %.2f \n",sum/10);
getch();
return 0;
}
int max (int c[][5])
{
int i,j;
int maxi=c[0][0];
for (i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
if (maxi<c[i][j])
maxi =c[i][j];
}
}
return maxi;
}
int min (int c[][5])
{
int i,j;
int mini=c[0];
for (i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
if (mini>c[i][j])
mini =c[i][j];
}
}
return mini;
}
int max (int [][5]);
int min (int [][5]);
int main()
{
int c[2][5];
int i,j;
float sum=0;
printf("Please enter elements of 2-D array of 2 rows and 5 columns:");
for(i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
scanf("%d",&c[i][j]);
sum=sum+c[i][j];
}
}
printf("Your elemnts are\n\n");
for(i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
printf("%8d\n",c[i][j]);
}
}
printf("\nSum of your array is : %.2f \n",sum);
printf("Maximum Number of your array is : %d \n",max (c));
printf("Minimum Number of your array is : %d \n",min (c));
printf("Average Number of your array is : %.2f \n",sum/10);
getch();
return 0;
}
int max (int c[][5])
{
int i,j;
int maxi=c[0][0];
for (i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
if (maxi<c[i][j])
maxi =c[i][j];
}
}
return maxi;
}
int min (int c[][5])
{
int i,j;
int mini=c[0];
for (i=0;i<2;i++)
{
for(j=0;j<5;j++)
{
if (mini>c[i][j])
mini =c[i][j];
}
}
return mini;
}
No comments:
Post a Comment