+ 1

How to find Average elements of integers in c program

7th Apr 2018, 9:48 PM
Nishad Nishad
Nishad Nishad - avatar
3 Answers
0
public int Average(int[] elements){ int sum = 0; for(int i=0; i < elements.length; i++){ sum += elements[i]; } return sum/elements.length; }
7th Apr 2018, 9:51 PM
Ariela
Ariela - avatar
0
int b=0, n=0; cin>>n; float *a=new float [n]; for(int m=0;m<n;++m) cin>>a[m]; for(int i=0;i<n;++i) for(int j=i+1;j<n;++j) for(int k=0;k<n;++k) if ((a[i]+a[j])/2==a[k]) ++b; cout<<b; return 0; will you convert it into c
7th Apr 2018, 9:53 PM
Nishad Nishad
Nishad Nishad - avatar
0
Here's a solution: https://code.sololearn.com/cPY5aQ1KLqwk/?ref=app Good code has good layout, and comments!
7th Apr 2018, 10:22 PM
Emma