Hello all. I'm so new in C++ Programming that a simple problem seems extremely difficult!! The only thing that I have to do is to calculate the sum, the average, the max and the min of 10 numbers given by the user!! My code is:
But when I try to execute the latter some errors appear, which are:Code:#include <iostream> using namespace std; int count_sum(int numbers_par[]); void count_max(int numbers_par[]); void count_min(int numbers_par[]); int main() { int numbers[10]={0,0,0,0,0,0,0,0,0,0}; int sum; double average; cout<<"Enter 10 integers.\n"; for(int i=0; i<10; i++) cin>>numbers[i]; sum = count_sum(numbers[10]); average = sum/10.0; cout<<"average "<<average<<endl; count_max(numbers[10]); count_min(numbers[10]); return 0; } int count_sum(int numbers_par[]) { int sum=0; for(int i=0;i<10;i++) sum = sum+numbers_par[i]; cout<<"sum "<<sum<<endl; return sum; } void count_max(int numbers_par[]) { int max=0; for(int i=0;i<10;i++) if(numbers_par[i]>max) max=numbers_par[i]; cout<<"max "<<max<<endl; } void count_min(int numbers_par[]) { int min=numbers_par[0]; for(int i=0;i<10;i++) if(numbers_par[i]<min) min=numbers_par[i]; cout<<"min "<<min<<endl; }
1. error C2664: 'count_sum' : cannot convert parameter 1 from 'int' to 'int []'
2. error C2664: 'count_max' : cannot convert parameter 1 from 'int' to 'int []'
3. error C2664: 'count_min' : cannot convert parameter 1 from 'int' to 'int []'
Does anybody know how can I recover from all the above errors? Thanks a lot!



LinkBack URL
About LinkBacks


