i'm new at programming. i'm currently making a rot13 program in c, i tried using "for","if" and it works untill letter f it shows question mark. if i were to write letters from a-z the encrypted results is like : nopqrstuvwxyzabcde???????? . i tried to change the addition/substraction values, the variable, the int. it didn't came out well.
#include<stdio.h>
int main()
{
char message[100], ch;
int i;
printf("Enter a message to encrypt: ");
gets(message);
for(i = 0; message[i] != '\0'; ++i){
ch = message[i];
if(ch >= 'a' && ch <= 'z'){
ch = ch + 13;
if(ch > 'z'){
ch = ch - 26;
}
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + 13;
if(ch > 'Z'){
ch = ch - 26;
}
message[i] = ch;
}
}
printf("Encrypted message: %s", message);
return 0;
}