Skip to main content
6 votes
Accepted

Pset3 Helpers.c Frequency Not Working

For "A4", this returns 440 for me. Note that C's ^ operator is bitwise XOR, not power. Also, in C, 1/12 equals 0 (integer division truncates, you could avoid this by using floating point values like ...
Blauelf's user avatar
  • 21k
3 votes
Accepted

Problem with pow() function, int frequency, helpers.c, pset3, music

(pow(2, index / 12) the issue is that both index and 12 are integers, so with integer division, the result will always be a whole number. Try using 12.0 instead of 12 to force a floating point ...
curiouskiwi's user avatar
  • 18.7k
2 votes
Accepted

Music frequency accidental and note issue

When you write 9/12, that's an integer division. Integer division results in an integer again, truncating the result. You want a floating point division instead. For that, make at least one of the ...
Blauelf's user avatar
  • 21k
1 vote

Need help with Frequency in pset3. Been stuck for a while

IMPORTANT NOTE This exercise is not included in CS50x 2019. The courseware changed at the beginning of 2019; music has been retired. Which is not to say you shouldn't persevere. But as far as I know, ...
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset3 Frequency Algorithm

Your semitones should be relative to A of the same octave. But C of the same octave is -9 semitones, not +3. That one would be C of the next octave, explaining the double frequency the test found.
Blauelf's user avatar
  • 21k
1 vote

signed integer overflow

The issue with this was that I have signed char to int and havent changed anything. I asummed that if char is 4 that the int will be also 4 but it is not (its 52) so that's why my loop was giving so ...
koko loko's user avatar
1 vote
Accepted

pset3 load of null pointer of type 'char'

You can use note as a char * or as a char[], because it is a string. So you can use it as an array of char's, or as a pointer to a char. But you are using it as a pointer to a char[] ... You should ...
Peter Pesch's user avatar
  • 1,009
1 vote
Accepted

Why are these if-else statements not letting my program compile?

Look at the following code: if(octave == 4) { if(note[0] == 'A' && accidental == '#') answer = (440 * pow((double)2, (double)1/12)); return answer; else if(note[0] == ...
Cliff B's user avatar
  • 69.3k
1 vote
Accepted

PSET3 - Frequency giving wrong octave result

note[strlen(note) - 1] is the ASCII value of the digit. You would need to subtract the character '0' (that's same as subtracting 48) to find the value you expect. So you could use note[strlen(note) - ...
Blauelf's user avatar
  • 21k

Only top scored, non community-wiki answers of a minimum length are eligible