Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 General C++ Help
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
canmovie




PostPosted: Sun Jan 27, 2013 4:46 pm   Post subject: General C++ Help

I'm studying for a test and did the some practice questions, but there is no answer sheet, so I can't actually check my answers.

http://imgur.com/a/UdZse

Could someone help me check those answers? I've googled some but some questions are not too clear and I'm not sure about them.
Also, for number 6, the right answer which is 0xA3E4 isn't one of the multiple choice options, that's a mistake on the test right?
The only other one I'm not sure about is number 13.

Wouldn't take more than a minute to quickly look over this practice test.
Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
TerranceN




PostPosted: Sun Jan 27, 2013 5:57 pm   Post subject: RE:General C++ Help

The only problem I saw was on 5. two bytes can count up to 2^(2*8 - 1) = 32768 which is too low, but four bytes can go up to 2^(4*8 - 1) = 2147483648, therefore it must be d) 4

For 6 I agree it should be 0xA3E4

For number 4 it's unclear if they are trying to trick you by not telling you the type of i or just forgot to mention it.

13 seems correct.
QuantumPhysics




PostPosted: Wed Jan 30, 2013 10:44 am   Post subject: RE:General C++ Help

2. e (unless your teacher reads from the textbook)
5. d
6. None of those
7. 0 times, do {
asm(
reg ebx,50
pop ebx
)
}while(int __cdecl ebx = 0);
13. I think it would be (d) because even though they all swap, out of those the best would be search because as it moves through passes it still has find if one number is greater than the other.
Panphobia




PostPosted: Wed Jan 30, 2013 11:30 am   Post subject: Re: RE:General C++ Help

QuantumPhysics @ Wed Jan 30, 2013 10:44 am wrote:
2. e (unless your teacher reads from the textbook)
5. d
6. None of those
7. 0 times, do {
asm(
reg ebx,50
pop ebx
)
}while(int __cdecl ebx = 0);
13. I think it would be (d) because even though they all swap, out of those the best would be search because as it moves through passes it still has find if one number is greater than the other.
a searching algorithm would be something like binary search or linear search, those are sorting algorithms, you dont search for the numbers so much as realize they are there and compare them
bl0ckeduser




PostPosted: Wed Jan 30, 2013 5:23 pm   Post subject: Re: General C++ Help

I would like to point out that the do-while is always run at least once.

He's a quote from a reputable source to back what I'm saying:

Quote:
The expression in a do-while statement is evaluated after the body of the loop is executed. Therefore, the body of the loop is always executed at least once.

Source: http://msdn.microsoft.com/en-us/library/8z1ch5dd%28v=vs.80%29.aspx

I agree with you for question one (b); I have learned the importance of operator precedence "the hard way".

For question 5, 4 bytes should be sufficient, see http://msdn.microsoft.com/en-us/library/s3f49ktz%28v=vs.80%29.aspx

I hope this helps.

edit: sorry, some typos (mismatched letters/numbers)
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: