So I am making a Caesar cipher program I have the encryption working just fine it is the decryption I am having trouble with.
Here is the code that works for encryption on uppercase letters:
if (isupper(p[i])){
char c = ((p[i] - 'A') + k % 26) + 'A';
}
Now I would think that decryption would be:
if (isupper(pp[i])){
char c = (abs((p[i] - 'A') - k) % 26) + 'A';
}
The issue that I'm having is that if k=1 and p[i]='A' it will just output the letter 'B' and not 'Z' it does not wrap around like it should so if k=2 and p[i]='A' it should output the letter 'Y'. It works if k=1 and p[i]='B' it will output 'A' thanks for any help.