#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int count=0;
int main(){
int n;
scanf(" %d",&n);
char *s = (char *)malloc(10240 * sizeof(char));
scanf(" %s",s);
int length=strlen(s);
char array[length+1];
int k;
scanf(" %d",&k);
while(*s!='\0')
{
char a= *s + k;
if(a>90 && *s<=90)
{
a=65+(k-1);
array[count]=a;
}
else if(a>122 && *s<=122)
{
a=97+(k-1);
array[count]=a;
}
else if (a >=0 && a<=64)
{
array[count]=a;
}
else if(a>=123 && a<=126)
{
array[count]=a;
}
count++;
s++;
}
array[count+1]='\0';
printf("%s",array);
return 0;
}
In the below code ,Each unencrypted letter is replaced with the letter occurring 'k' spaces after it when listed alphabetically. Think of the alphabet as being both case-sensitive and circular; if 'k' rotates past the end of the alphabet, it loops back to the beginning (i.e.: the letter after 'z' is 'a' , and the letter after 'Z' is 'A' ).
I am unable to get where I am going wrong ,it is printing null for every possible input sequence of letters .The special symbols don't change in the encrypted string .