help

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 5
Reputation: 3m4d is an unknown quantity at this point 
Solved Threads: 0
3m4d 3m4d is offline Offline
Newbie Poster

help

 
0
  #1
May 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 248
Reputation: hammerhead is an unknown quantity at this point 
Solved Threads: 24
hammerhead's Avatar
hammerhead hammerhead is offline Offline
Posting Whiz in Training

Re: help

 
1
  #2
May 11th, 2008
What is there you cannot understand? If you expect someone to hand out the answers then you are wrong.
Last edited by hammerhead; May 11th, 2008 at 6:09 am.
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,433
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 118
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: help

 
1
  #3
May 11th, 2008
sum1 plz
wna no
fank u
Use real words...
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: 3m4d is an unknown quantity at this point 
Solved Threads: 0
3m4d 3m4d is offline Offline
Newbie Poster

Re: help

 
0
  #4
May 11th, 2008
no i no what the answers are dont worry,lol

just wanted to no how it is
like Q3 i no the answer is C and stuff just wanted to no how it is
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,878
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: help

 
0
  #5
May 11th, 2008
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?
Last edited by niek_e; May 11th, 2008 at 2:23 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: 3m4d is an unknown quantity at this point 
Solved Threads: 0
3m4d 3m4d is offline Offline
Newbie Poster

Re: help

 
0
  #6
May 11th, 2008
i probably am a kid thats why im talking the way it is

and yeah we got the answers along with the questions, just wanted to know how it is that it works out to be that, could put up the answer if it helps
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 248
Reputation: hammerhead is an unknown quantity at this point 
Solved Threads: 24
hammerhead's Avatar
hammerhead hammerhead is offline Offline
Posting Whiz in Training

Re: help

 
0
  #7
May 11th, 2008
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.
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: 3m4d is an unknown quantity at this point 
Solved Threads: 0
3m4d 3m4d is offline Offline
Newbie Poster

Re: help

 
0
  #8
May 11th, 2008
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"
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: help

 
0
  #9
May 11th, 2008
> With Q4 the answer is D 12.0 but if u work it out you get 12.5 ??
Think about the difference between integer division, and float division.
Which applies in this case?

> else cout>>"there"
Consider which of the 'if' statements this else statement binds to?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: 3m4d is an unknown quantity at this point 
Solved Threads: 0
3m4d 3m4d is offline Offline
Newbie Poster

Re: help

 
0
  #10
May 11th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC