write a C program to convert the string "CEASER " to "HJFXJW "without using inbuilt function
#include<stdio.h>
int main()
{
char s[100]="CEASER";
char ch;
int i, key;
key=5;
for(i = 0; s[i] != '\0'; i++){
ch = s[i];
if(ch >= 'a' && ch <= 'z'){
ch = ch + key;
if(ch > 'z'){
ch = ch - 'z' + 'a' - 1;
}
s[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + key;
if(ch > 'Z'){
ch = ch - 'Z' + 'A' - 1;
}
s[i] = ch;
}
}
printf("%s", s);
return 0;
}
Comments
Leave a comment