# PSET2 Caesar Bug in Uppercase Case For Loop

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?

`````` if (plain [i] >= 66 || plain[i] <=90) //case for upper case letters
{"ft_lang_label":"__label__en","ft_lang_prob":0.9024358,"math_prob":0.96066946,"size":1159,"snap":"2022-40-2023-06","text_gpt3_token_len":318,"char_repetition_ratio":0.13766234,"word_repetition_ratio":0.027906977,"special_character_ratio":0.30888698,"punctuation_ratio":0.09663866,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.964044,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-10-06T08:16:57Z\",\"WARC-Record-ID\":\"<urn:uuid:6ef1a17f-aeef-4b20-8a87-5498097acdfe>\",\"Content-Length\":\"106481\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c3b5c4aa-f8d6-4aee-80f4-e04135351393>\",\"WARC-Concurrent-To\":\"<urn:uuid:507b902c-c5eb-4483-9cbe-ac2f52899329>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://cs50.stackexchange.com/questions/26977/pset2-caesar-bug-in-uppercase-case-for-loop/26979\",\"WARC-Payload-Digest\":\"sha1:T3KVGFCZWY5FBGROYE7EBYNRYNWP5Z7J\",\"WARC-Block-Digest\":\"sha1:EIQYFHYCR5KNQIDWK2PII5O3NYXI5NCI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030337731.82_warc_CC-MAIN-20221006061224-20221006091224-00198.warc.gz\"}"}