Create encrypted string using the given input string

The string is encrypted using the ASCII value.Input is accepted and stored in variable str.The ASCII value of 'A' is 65 and 'Z' is 90.The ASCII value of 'a' is 97 and 'z' is 122.So the ASCII value calculated after encryption should lie between two subsets i.e 65 to 90 and 97 to 122.The variable new_code is used to get the new encrypted ASCII value.If the ASCII value of variable new_code goes beyond the two subsets i.e 65 to 90 and 97 to 122 ,then it is adjusted by adding or subtracting the difference.Encryption is performed character by character and the final encrypted string is stored in variable str.

#include < stdio.h >
#include < conio.h > 

void main()
{
	char str[100];
	int diff,new_code,key;
	int i;
	clrscr();
	printf("\nEnter a string \n");
	gets(str);
	printf("\nEnter a key : ");
	scanf("%d",&key);
	key = key % 27;
	for(i=0; str[i] != '\0' ; i++)
	{
		if ( str[i] >= 'a' && str[i] <= 'z' )
		{
			new_code = str[i] + key;
			if( new_code > 'z' )
			{
				diff = new_code - 'z' - 1;
				str[i] = 'a' + diff;
			}
			else
			if ( new_code < 'a' )
			{
				diff = 'a' - new_code - 1;
				str[i] = 'z' - diff;
			}
			else
				str[i] = new_code;
			}
			else
			if ( str[i] >= 'A' && str[i] <= 'Z' )
			{
				new_code = str[i] + key;
			if( new_code > 'Z' )
			{
				diff = new_code - 'Z' - 1;
				str[i] = 'A' + diff;
			}
			else
			if ( new_code < 'A' )
			{
				diff = 'A' - new_code - 1;
				str[i] = 'Z' - diff;
			}
			else
				str[i] = new_code;		
		}	
	} // for
	printf("\nThe encrypted string is \n");
	puts(str);
} // main