Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2010
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2010 by Ivor Horton; ISBN: 9780470500880
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2010 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 23rd, 2013, 11:41 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Facepalm *spoilers*

Just wanted to share that I spent 4 hours+ scratching my head on the second exercise of Chapter 2.

It basically reads:

Write a program that reads an integer into an int, and uses one of the bitwise operators to determine the positive remainder, when divided by 8.

I don't know about anyone else, but I took that literally: Use a bitwise operator to determine the remainder. Felt like pounding my head against the wall. Technically, while you use a bitwise operator to divide and multiply (discarding the remainder), to actually isolate the remainder, you use ordinary subtraction - a method which I'd figured out in the first five minutes. You can't isolate the remainder purely by using bitwise operators, at least not without maybe knowing binary and hexadecimal really well, which I don't.

Now I'm going to chill out and attempt to approach the rest of this book less logically >>
  #2 (permalink)  
Old May 23rd, 2013, 01:44 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Interloper,

Please read the whole reply. It seems a little off topic at first, but it concludes by addressing your frustration.

Yep, I had problems with this one also. I went from facepalm to lightbulb to slapforehead.

The lightbulb was an algebra classroom lecture (too many years ago) where we were asked how to solve a problem using a specific method similar to, "uses one of the bitwise operators to determine the positive remainder, when divided by 8," in the exercise. In unison the class said that the specific method would not supply the solution, like saying, "you can't isolate the remainder purely by using bitwise operators."

The teacher's reply was that the specific method was not the only tool available. It was simply a tool he required us to use. As long as we used the required tool, the use of other other appropriate tools in conjunction with the required tool to complete the solution satisfied his requirements.

He went on to give a real world example of given some wood, use a hammer to build a box. It is both appropriate and necessary to use a saw to cut the wood into the proper sizes and shapes and then use a hammer to complete the construction of the box.

He concluded by saying that the problem he had posed to the class was not intended to mechanically crunch out some numbers. It was intended to require thought.

The moral of the story is:
Don't, "attempt to approach the rest of this book less logically." Attempt to avoid taking it too literally. Being too literal can suppress thought. That is the slapforehead I experienced.

I hope this is both encouraging and helpful.

drpepper
  #3 (permalink)  
Old May 24th, 2013, 04:23 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply. I did put significant thought into the ways the problem could be achieved, when taken literally. Think I rewrote the program 3-4 times but I wasn't satisfied that I was solving the issue as it had been presented - I didn't want to cheat, because I suspected maybe I was simply missing something in my understanding of the bitwise operators. This book was my first time reading about/using them. I also re-read the question about ten times to confirm I was reading it correctly -_-

I'm not normally one to think inside a box.. maybe except for when it comes to language. I take people literally. Independently, I would have solved the issue in the most efficient way I could see, in a couple of minutes.

Thanks for your reply, it was encouraging :)
  #4 (permalink)  
Old May 24th, 2013, 12:10 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You're welcome. I did gather that you put a lot of thought into the solution, and I applaud that. One word of warning about some of the exercises seems prudent.

I have run into some exercises which assume knowledge of concepts not covered in the book. I don't know if this is by intent to promote research, a product of revisions as newer Visual C++ are released, or other reasons. Just be forewarned. In a classroom environment the instructor can clarify these issues. Unfortunately I am studying the book as an independent learning project.

This brings me to the subject of the code supplied online. A couple of times I have had to resort to examining the solution (and maybe some supplemental research) to understand the recommended solution. I have also found that comparing my solution to the provided solution is instructive. Upon comparison I may find that there is a better, more concise, or cleaner solution to mine. I believe this will serve me better as I progress from the simple problem solving to more advanced programming. (Ugly code can present a problem when debugging or returning to the code at a later date to view it or add features to a program.) I just thought I'd share that with you.

Meanwhile the demands of everyday life have taken me away from my Visual C++ studies. I am starting over at Chapter 1 to refresh the skills I learned on the first go around.

I don't know if you like flowcharting or not, but I find it helpful when attacking more complex solutions or when reviewing code at a later date. It is a tool I like.

Good luck to you in your studies.

drpepper
  #5 (permalink)  
Old May 24th, 2013, 05:47 PM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the tips :) I'm studying the book independently as well, coming from a rusty background in vanilla C++. I'll keep your suggestions in mind.
  #6 (permalink)  
Old May 24th, 2013, 05:51 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You're welcome. I'll stay subscribed to the forum.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 01:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.