Could sum1 plz help me undastand these Questions
just wna no how it is done
fank u
3. If DoSomething is a void function that takes an int expression as an argument, which of the following is an incorrect statement? (Assume all variables are int variables.)
A) DoSomething(n);
B) DoSomething(3*n + 24);
C) length = DoSomething(width);
D) b and c above
E) a, b, and c above
4. Given that x is a float variable and num is an int variable containing the value 38, what will x contain after execution of the following statement:
x = num / 4 + 3.0;
A) 12.5
B) 13
C) 12
D) 12.0
E) nothing; a compile-time error occurs
10. Given the constant declaration
const int FACTOR = 95;
which of the following is not a valid use of FACTOR?
A) cout << FACTOR * 3;
B) FACTOR = 24;
C) cin >> FACTOR;
D) a and c above
E) b and c above
14. Assuming alpha and beta are int variables, what is the output of the following code (which is indented poorly)?
alpha = 3;
beta = 2;
if (alpha < 2)
if (beta == 3)
cout << "Hello";
else cout << "There";
A) Nothing is output.
B) Hello
C) There
D) HelloThere
27. The function heading
float TenToThePower( /* in */ int n )
is for a function that returns 10.0 raised to any integer power. Which of the following statements represents an appropriate use of the TenToThePower function?
A) someFloat = 4.96 * TenToThePower(8) + 2.5;
B) TenToThePower(6);
C) if (TenToThePower(someInt) > someFloat)
beta = 3;
D) a and b above
E) a and c above
29. Given the function definition
int Mystery( /* in */ float someVal )
{
if (someVal > 2.0)
return 3 * int(someVal);
else
return 0;
}
what is the value of the expression Mystery(4.2) ?
A) 12
B) 12.0
C) 0
D) 0.0
E) nothing--the function call is invalid
35. Which of the following is a valid use of the C++ cast operation?
A) gamma = short(delta);
B) beta = (long double) alpha;
C) beta = long double(alpha);
D) a and b above
E) a, b, and c above
38. Given the declarations
enum MovieRatings {G, PG, PG13, R, X};
MovieRatings thisOne;
and assuming that thisOne currently contains a value less than X, which of the following statements can be used to "increment" thisOne?
A) thisOne = thisOne + 1;
B) thisOne++;
C) MovieRatings(thisOne++);
D) thisOne = MovieRatings(thisOne + 1);
E) thisOne = MovieRatings(thisOne) + 1;
39. Given the declarations
struct RecType1
{
int length;
float width;
};
struct RecType2
{
int length;
float width;
};
RecType1 myRec;
RecType2 yourRec;
which of the following assignment statements is valid?
A) myRec.length = yourRec.length;
B) myRec = yourRec;
C) myRec.length = yourRec;
D) a and b above
E) none of the above
41. Assume that myclass.h and myclass.cpp are files for a class MyClass and that someprog.cpp is a client of class MyClass. Which file(s) must #include the file myclass.h?
A) someprog.cpp
B) myclass.cpp
C) myclass.h
D) a and b above
E) a, b, and c above
42. Consider the class declaration
class SomeClass
{
public:
void Func();
private:
int m;
int n;
};
and client code
SomeClass alpha;
SomeClass beta;
...
Considering both pieces of code above, which identifiers are names of class objects?
A) m and n
B) alpha and beta
C) SomeClass, m, and n
D) alpha, beta, m, and n
E) Func, m, and n
45. After execution of the code fragment
int arr[5];
int i;
for (i = 0; i < 5; i++)
{
arr[i] = i + 2;
if (i >= 3)
arr[i-1] = arr[i] + 3;
}
what is contained in arr[1]?
A) 2
B) 3
C) 7
D) 8
E) none of the above
51. What does the following C++ statement do?
ptr = new RecType;
A) It allocates a dynamic variable named ptr.
B) It allocates a dynamic variable and stores the address into ptr.
C) It deallocates the variable ptr.
D) It deallocates the dynamic variable that is pointed to by ptr.
52. Given the declaration
int* somePtr;
which of the following is a valid statement?
A) somePtr = new int*;
B) delete somePtr;
C) delete *somePtr;
D) a and c above
E) a, b, and c above
57. Given the declarations
struct ListNode
{
float volume;
ListNode* link;
};
ListNode* ptr;
what is the data type of the expression ptr.volume ?
A) ListNode*
B) ListNode
C) float
D) *ListNode
E) none--the expression is invalid