{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework6-1 - fflush(stdin scanf"%s",WORD/stores...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #6 /* * Program: Palindrome check function * Written by Justin Waters * Inputs: User enters a word to be checked * Outputs: Tells user if the entered word is a palindrome * Description: The program lets a user enter a word and checks to see if its a palindrome or not. * */ #include <stdio.h> #include <string.h> #include <ctype.h> #define MAX 40 int main (void) { unsigned char WORD[MAX]; //storage for users word unsigned int i,n,a; printf("\nWelcome to my palindrome checker\n"); printf("\nEnter a word you would like to be checked:\n\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fflush(stdin); scanf("%s",WORD); //stores users word //loop to convert word to all uppercase for comparison for (i=0;i<strlen(WORD);++i) if (islower(WORD[i])) WORD[i] = toupper(WORD[i]); n = strlen(WORD);//counts # of letters in word //loop for comparing corresponding front and back letters for (a=0;a<=n;a++) { if(WORD[a] == WORD[n-1]){ n--;} else { printf("\n\n%s is not a palindrome",WORD); return (0); } } printf("\n\n%s is a palindrome",WORD); return (0); }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Homework6-1 - fflush(stdin scanf"%s",WORD/stores...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online