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!
Great job! Please note that there are at least two unnecessary “if” loops: 1) this segment: given_octave = atof(¬e[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(¬e[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 »
Thank you! That is a good point. I hope this article was helpful. Your comment helped me understand a better way to solve this problem set, and i’m sure it will help other programmers who read the comments. Happy new year to you!