1. 2. 3. Consider the following code double foo(int count,double base) { return
ID: 3541003 • Letter: 1
Question
1.
2.
3.
Consider the following code
double foo(int count,double base)
{
return count * base;
}
int main (void)
{
int n=5;
double y= 1.1;
double x= foo(n, y);
// statements to do more work, etc.
}
The call to foo copies the value of n to count, copies the value of y to base, and returns the product of count and base.
It will not compile because of there is no function prototype provided.
It will compile, but will not work correctly since y is passed by value.
The variable n is passed by value and is protected, but the variable y is passed by reference and is not protected.
4. 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
Explanation / Answer
please rate - thanks
Testing selection statements (Points : 5)
3.
Consider the following code
double foo(int count,double base)
{
return count * base;
}
int main (void)
{
int n=5;
double y= 1.1;
double x= foo(n, y);
// statements to do more work, etc.
}
The call to foo copies the value of n to count, copies the value of y to base, and returns the product of count and base.
4. 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;
each int is 32 bits or 4 bytes
therefore
&data[0]=x'5000'
&data[1]=x'5004'
.
.
.
&data[20]= x'5000'+(20*4)
= x'5000'+80
convert 80 to hex=50
so the answer is X'5050'
so none is correct
however if address 5000 was in decimal
then it would be 5000 + 80 = 5080 --but this answer is mixing hex and decimal and addresses are in hex
0.0
5020
5080
unknown
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.