1) What does the following function do? double calc ( double data[ ], int size )
ID: 3635737 • Letter: 1
Question
1) What does the following function do?double calc ( double data[ ], int size )
{
double s = 1;
for(int i = 0; i < size; i++)
{
s *= data[i];
}
return(s);
}
- Returns the product of all the values in the data array
- Does nothing because the data array does not exist
- Fails because the size of the array is not known
- Returns the sum of the values in the data array
2) The last data element in foo is _______.
const int MAX = 500;
double foo[MAX] = {0.0};
- foo[MAX]
- foo[500]
- foo[MAX - 1]
- None of the above
3) What will the third statement in the following code snippet do?
const int MAX = 500;
double foo[MAX] = {0.0};
foo[MAX] = 1.1;
- assign the value 1.1 to the last array element.
- it compiles but causes a run-time error.
- cause a compiler error.
- None of the above
4) A ______ identifier is declared within a function. A ______ identifier is declared outside of every function definition.
- local; global
- global; local
- local; static
- static; global
5) Which of the following functions would correctly copy C string s2 to C string s1?
- strcpy(s2, s1) ;
- strcmp(s1, s2) ;
- strcpy(s1, s2) ;
- stringcopy(s2, s1) ;
Explanation / Answer
Dear user,
Solutions are:
1) Returns the product of all the values in the data array
2) foo[MAX - 1]
3) it compiles but causes a run-time error.
4) local; global
5) strcpy(s1, s2) ;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.