Wednesday, 20 February 2013

A program to calculate sum and average of array element


#include<iostream.h>
usinf namespace std;
main( )
{
float abc[4] ,  sum, avg;
int  i;
for(i=0;i<=3;i++)
{
cout<<"enter the value"<<i<<endl;
cin>>abc[i];
}
sum=avg=0.0;
for(i=3;i>=0;i--)
sum=sum+abc[i]
avg=sum/4.0;
cout<<sum<<endl;
cout<<avg;
}

No comments:

Post a Comment