#include <stdio.h>
#include <stdlib.h>

#define MAXLEN (50+1)

int cypher(char source[], char destination[],int key)	{
	int i;
	char e;
	for(i = 0; source[i] != '\0' && i <= MAXLEN; i++)	{
		if(source[i] == ' ')	putchar(source[i]);
		e = ((source[i] - 32) + key) % 26;
		if(e > 94)	{
			e -= 93;
		}
		destination[i] = e + 32;
	}
	destination[i] = '\0';
	return 0;
}


int main(void)	{
	char source[MAXLEN], destination[MAXLEN];
	int key;
	printf("Enter text to encrypt: ");
	scanf("%s",source);
	printf("Enter encryption key: ");
	scanf("%d",&key);
	cypher(source,destination,key);
	printf("Source:\n %s\nEncrypted:\n %s\n",source,destination);
	return 0;
}
