C++ Programs & Stuffz

Nothing like anything!!!

Please Click on ADS!!

Please Click on the above ads given by GOOGLE , so that I can maintain my blog!!

Tuesday, August 31, 2010

Find the sum and average of m lists of n numbers

//pgm to find the sum and average of m lists of n numbers
#include<iostream.h>
#include<conio.h>
void main()
{
    int i,x,n,m,j;
    float sum1,sum,average1,average;
    clrscr();
    sum=0;
    cout<<"enter the value of m"<<endl;
    cin>>m;
    for(i=1;i<=m;i++)
    {
        cout<<"enter the value of n";
        cin>>n;
        cout<<"enter the numbers";
        sum1=0;
        for(j=1;j<=n;j++)
        {
            cin>>x;
            sum1=sum1+x;
        }
        average1=sum1/n;
        sum=sum+average1;
    }
    average=sum/m;
    cout<<"sum="<<sum;
    cout<<"average="<<average;
    getch();
}

0 comments:

Post a Comment

free counters