All pastes #17423 Raw Edit

Miscellany

public text v1 · immutable
#17423 ·published 2005-07-11 04:01 UTC
rendered paste body
/* Rodney Biggs      Summer 2005 */
/* COP 3223    prg3.c    6/27/05 */
/*       Sentence encoder        */

#include <stdio.h>

/* The following code takes a sentence or sentences entered by the user */
/* and converts it into a code.  X's, Y's and Z's are rolled over into  */
/* the beginning of the alphabet.													*/

int main(void)
{
	printf("\nPlease type in a sentence or sentences and hit Enter.\n");
	printf("To end the program, hit ctrl+Z\n\n");
	
	int c;
	
	while ((c = getchar()) != EOF)
		
		if (c == ' ')
			putchar(' ');
		else if (c == 'x')
			putchar('a');
		else if (c == 'X')
			putchar('a');
		else if (c == 'y')
			putchar('b');
		else if (c == 'Y')
			putchar('b');
		else if (c == 'z')
			putchar('c');
		else if (c == 'Z')
			putchar('c');
		else if (isalpha(c))
			putchar(c + 3);
		else 
			putchar(c);
			
	return 0;
}