| | |
help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 5
Reputation:
Solved Threads: 0
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
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
You should stop talking like a kid. 'No' and 'know' are two different words. You could also use some CAPS. Read the rules (the part called 'keep it clean')
But on topic: how do you know that the answer is 'c' if you don't know why?
If the teacher gave you the answers you could ask him for help right?
But on topic: how do you know that the answer is 'c' if you don't know why?
If the teacher gave you the answers you could ask him for help right?
Last edited by niek_e; May 11th, 2008 at 2:23 pm.
Lets take Q3, you have to know that void means that the function does not return any value. That means that option C is incorrect and A is perfectly valid. Option B is where one might get stuck, but since 3*n + 24 amounts to an int, option B is also valid. That means that only option C is incorrect and hence C is the answer.
Why dont you give a shot at all the questions in similar manner and post here why you think a option is the answer. We will correct you if you are wrong.
Why dont you give a shot at all the questions in similar manner and post here why you think a option is the answer. We will correct you if you are wrong.
There are 10 types of people in the world, those who understand binary and those who don't.
All generalizations are wrong. Even this one.
All generalizations are wrong. Even this one.
•
•
Join Date: May 2008
Posts: 5
Reputation:
Solved Threads: 0
Thanks
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
With Q4 the answer is D 12.0 but if u work it out you get 12.5 ??
Q10 ive worked out now
Q14:
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
the answer is A)
but i thought it would b C)there as it fails on both the if's and it said
else cout>>"there"
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
With Q4 the answer is D 12.0 but if u work it out you get 12.5 ??
Q10 ive worked out now
Q14:
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
the answer is A)
but i thought it would b C)there as it fails on both the if's and it said
else cout>>"there"
•
•
Join Date: May 2008
Posts: 5
Reputation:
Solved Threads: 0
integer division
and the else statement is binded to the second IF statement ?
but say right that the first IF statement was to work and the second didnt what would have been the outcome then ?
Question 27 is something which i havnt understood at all
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
and the else statement is binded to the second IF statement ?
but say right that the first IF statement was to work and the second didnt what would have been the outcome then ?
Question 27 is something which i havnt understood at all
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
![]() |
Other Threads in the C++ Forum
- Previous Thread: Problems with threads in Borland C++ Builder3.
- Next Thread: Select Row in dataGridView
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






