All pastes #264874 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-02 20:13 UTC
rendered paste body
/* backwards.c - Script 6.6 */

#include <stdio.h>
#include <ctype.h> 

int main(void) {
// Variables
char input[11]; // for keyed input
int i; // Index loop variable
char junk; // Get rid of extra input

// Prompt user to input
printf ("Enter a word up to ten characters long: ");
scanf ("%10s", input); // Assign input to input array
// Reprint entered word
printf ("The word '%s' is '", input); // '<-- means to be continued with '

// Begin and define for loop in reverse
for (i = 9; 1 >= 0; i--) {
// print every character in reverse
if (isalpha(input[i])) {
	printf ("%c", input[i]);
}
}
// Complete feedback statement with ->>> '
printf ("' spelled backwards.\n");

//Ignore extra characters
do {
	junk = getchar();
} while (junk != '\n');

//Complete main function
getchar();
return 0;
}