Posted by MindBreaker at 1:45 AM
Read our previous post
Object:
Write a program which find out
the  average of the numbers in an array
Source Code;
//
Average numbers of Array
#include <iostream>
using namespace std;
class
average
{
public:
       int
sum,calculate;
       int cal(int ary[10])
       {
       sum=0;
       for(int i=0;i<10;i++)
       {
              sum=sum+ary[i];
       }
       calculate=sum/10;
       return
calculate;
       }
};
void
main()
{
       average avg;
       int
i,arry[10],retrn;
       cout<<"Enter
numbers in array : \n";
       for(i=0;i<10;i++)
       {
       cin>>arry[i];
       }
       retrn=avg.cal(arry);
       cout<<"Average
of Array is : "<<retrn<<endl;
}
Output:
 
 
 
 
 
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.