Welcome Guest | Sign in | Register
Functions - Discussion Page For Q.10758 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Functions > Questions and Answers

Q: A function called total, totals the sum of an integer array passed to it (as the first parameter) and returns the total of all the elements as an integer. Let the second parameter to the function be an integer which contains the number of elements of the array.
A. function 1
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop < elements; loop++ )
total = total + numbers[loop];
return total;
}
B. function 2
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop <= elements; loop++ )
total = total + numbers[loop];
return total;
}
C. function 3
int total( int numbers[], int elements ) {
int total, loop;
for( loop = 0; loop > elements; loop++ )
total = total + numbers[loop];
return total;
}
D. None of these

Answer and Explanation

Answer:function 1
int total( int numbers[], int elements ) {
int total = 0, loop;
for( loop = 0; loop < elements; loop++ )
total = total + numbers[loop];
return total;
}

Explanation:
There is no explanation...

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.