Answer to Question #215987 in C for Hemambar

Question #215987
write a C program to convert the string "CEASER " to "HJFXJW "without using inbuilt function
1
Expert's answer
2021-07-15T00:09:50-0400
#include<stdio.h>
 
int main()
{
char mes[100] = "CEASER", chr;
int x, key = "HJFXJW";
printf("CEASER to be encrypted\n");


printf("The key is: HJFXJW\n ");


for(x = 0; mes[x] != '\0'; ++x){
chr = mes[x];
if(chr >= 'a' && chr <= 'z'){
chr = chr + key;
if(chr > 'z'){
chr = chr - 'z' + 'a' - 1;
}
mes[x] = chr;
}
else if(chr >= 'A' && chr <= 'Z'){
chr = chr + key;
if(chr > 'Z'){
chr = chr - 'Z' + 'A' - 1;
}
mes[x] = chr;
}
}
printf("Encrypted message: %s", mes);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS