1. Place function prototypes before main() to a. avoid compilation errors. b. re
ID: 3639119 • Letter: 1
Question
1. Place function prototypes before main() to
a. avoid compilation errors.
b. reuse the function.
c. avoid run-time errors.
d. avoid linker errors.
2. What is wrong with this function?
void calcSum(int a, int b)
{
return a+b;
}
a. it is declared as void but returns an int.
b. Only a single variable can be returned.
c. "calcSum" is a reserved word.
d. Only the data type should be declared in the parameter list.
3. The code below is an example of what type of function?
int abs(int num)
{
if (num == 0)
num = -num;
return num;
}
Value-returning
Void
Subroutine
None of the above
4. What is the range of valid subscripts for the following array?
double list[10];
0 to 9
0 to 10
1 to 9
1 to 10
5. Given the following array declaration, if the array is stored starting at address 5000, what is the output of the following statement? Assume the code is for a 32 bit processor such as a Pentium.
int data[25] = {0};
cout << &data[20] << endl;
0.0
5020
5080
unknown
6. Given the following code which fills the array with values,
int X;
int data[100];
for(int i = 0; i <= X; i++)
{
data[i] = i;
}
what should the value of X be?
100
101
99
i
7. foo contains _______.
double foo[500] = {0.0};
500 double values
499 double values
one double value of 0.0
None of the above
8. 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
9. A variable declared before all blocks in a program is
visible to all functions defined in the program.
visible only to main.
visible only to the first block after it is declared.
not visible to any functions; it will cause a compile error.
10. A C-Style string is an array of _______.
floats
integers
characters
doubles
11. 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
1.avoid compilation errors. 2.it is declared as void but returns an int 3.Value-returning 4.0 to 9 5.5080 6.100 7.500 double values 8.it compiles but causes a run-time error 9.visible to all functions defined in the program. 10.characters 11.strcpy(s1, s2) ;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.