having an issue with caesar.c. I've got a loop working for lowercase cases where the key size would cause the key to loop out of alphanumeric characters, but when I try to implement the same loop for uppercase characters it does not work for some reason. The code goes as follows
if (plain [i] >= 66 || plain[i] <=90) //case for upper case letters
{
if(plain[i]+k > 90) //case for "overflow" loop
{
if((plain[i] + (k%26) > 90)) //if modulo would send out of range
{
plain[i] = plain[i] - 26 + k%26; //kick loop back 26 letters, then increment by remainder of key/26
}
else
{
plain[i] = plain[i] + (k%26);//else increment by modulo key
}
}
else
{
plain[i] = plain[i] + k; //else increment by key
}
}
This works well for lowercase, where lowercase r, key of 65, goes to e as expected. However, with uppercase R, key of 65, it goes to _. This means that it is, for some reason, hitting the "increment by key mod 26" logical statement, instead of kicking the loop back by 26 letters and then incrementing by key mod 26. This is despite the fact that R plus 13 is greater than 90, which should be caught by the "if" statement. Any idea why that might be happening?