Twitter Feed Facebook Google Plus Youtube

Adsense responsive

Recent Post below header

Wednesday 30 January 2013

C PROGRAM: TO CALCULATE ARITHMETIC MEAN OF EACH ROW OF MATRIX

CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],m,n,i,j,sum;
double am[10];
clrscr();
printf("Enter order of matrix ");
scanf("%d%d",&m,&n);
printf("Enter values of matrix\n");
for(i=1;i<=m;i++)
{
 sum=0;
 for(j=1;j<=n;j++)
 {
  printf("Enter value of a[%d][%d] ",i,j);
  scanf("%d",&a[i][j]);
  sum=sum+a[i][j];
 }
 am[i]=(double)sum/n;
}
for(i=1;i<=m;i++)
{
  printf("\nArithmetic Mean of row %d = %f",i,am[i]);
}
getch();
}


CODING


OUTPUT


For any query or suggestion please comment below...

2 comments:

  1. what is the code if i want to find the mean of those calculated arithemtic mean for each row?

    ReplyDelete
    Replies
    1. For this, you havr to add all arithmetic mean values (i.e. array a[ ]) and divide it with number of values. That's all. You will need 'for' loop for this. If you want exact code for this then tell me, I will reply you with exact code as soon as possible.

      Till then, keep visiting.

      Delete