How to pass array structure to function to find average?
-
-
Answer:
int findavg(salary[]) { int avg; for(int i=0, avg=0; i<9;i++) avg+=salary[i]; // 9 is the number of elements. In fact you can chnage avg /= 9; return avg; } int findavg(salary[], int n) { int avg; for(int i=0, avg=0; i<n;i++) avg+=salary[i]; // 9 is the number of elements. In fact you can chnage avg /= n; return avg; }
Zack at Yahoo! Answers Visit the source
Other answers
int findavg(salary[]) { int avg; for(int i=0, avg=0; i<9;i++) avg+=salary[i]; // 9 is the number of elements. In fact you can chnage avg /= 9; return avg; } int findavg(salary[], int n) { int avg; for(int i=0, avg=0; i<n;i++) avg+=salary[i]; // 9 is the number of elements. In fact you can chnage avg /= n; return avg; }
James Bond
Related Q & A:
- How to pass multiple parameters in a single Ajax function?Best solution by stackoverflow.com
- How to pass javascript jQuery variable value in php array?Best solution by Stack Overflow
- How to pass an Array to AngularJS?Best solution by Stack Overflow
- How to pass a parameter to a function that is called on an event?Best solution by Stack Overflow
- How to determine the structure of a protein?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.