Answer to Question #218620 in C for Hemambar

Question #218620

write a C program to convert the string "CEASER " to "HJFXJW "without using inbuilt function


1
Expert's answer
2021-07-19T16:05:48-0400
#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;
}

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