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