We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Caesar Cipher: Encryption
Caesar Cipher: Encryption
Sort by
recency
|
53 Discussions
|
Please Login in order to post a comment
//Answer in java import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class cipher {
}
include
include
include
include
int main() { int n,i,k; char a[101]; scanf("%d %s %d",&n,a,&k); k%=26; for(i=0;i='a'){ if(a[i]+k>'z') a[i]-=26; a[i]+=k; } else if(a[i]<='Z'&&a[i]>='A'){ a[i]+=k; if(a[i]>'Z') a[i]-=26; } } printf("%s",a);
return 0; }
the code i wrote is :-
include
include
include
include
include
include
include
int main(){ int n; scanf("%d",&n); char s[100]; int a[100]; int i; for(i=0;i=65)&&(a[i]<=90)) {s[i]=((s[i]-64+k)%26)+64; printf("%c",s[i]); } else if((a[i]>=97)&&(a[i]<=122)) { s[i]=((s[i]-97+k)%26)+97; printf("%c",s[i]); } else printf("%c",s[i]);
}
{BUT WHY IS THIS CODE NOT WORKING IF I ENTER A SPECIAL CHARACTER IN BETWEEN?}