# Tag Info

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 ...
• 20.9k
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 ...
• 18.7k
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 ...
• 20.9k
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, ...
• 28.4k
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.
• 20.9k
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 ...
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 ...
• 999
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] == ...
• 68.7k
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) - ...
• 20.9k

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