CS50 Week 2: Walkthroughs

Any Questions?

I’m going to be working on my blog posts while doing the walkthroughs next time around. It’s hard to remember what exactly stumped me and how I got around it otherwise. Here are my solutions for the Week 2 walkthroughs. This project was difficult and frustrating for me. I found using the CS50 debugger was super super helpful in figuring out where I was going wrong. Use it to follow the values of variables throughout the program.

Leave a comment if you have any questions and i’ll do my best to answer them!



0 0 votes
Article Rating
Notify of
newest most voted
Inline Feedbacks
View all comments
4 years ago

Great job! Please note that there are at least two unnecessary “if” loops: 1) this segment: given_octave = atof(&note[octave_pos]); exponent = fabs(given_octave – STANDARD_OCTAVE); if ( given_octave > STANDARD_OCTAVE) frequency = STANDARD_HZ * pow(2, exponent); if ( given_octave <= STANDARD_OCTAVE) frequency = STANDARD_HZ / pow(2, exponent); is absolutely fine without the "if" loop because there is absolutely no need to calculate the absolute value of the exponent. You are fine like this: given_octave = atof(&note[octave_pos]); exponent = (given_octave – 4); frequency = 440.00 * pow(2, exponent); 2) The following segment int semitones = 0; char given_letter = note[0]; char white_keys[]… Read more »

Would love your thoughts, please comment.x