Homework6-1 - fflush(stdin);...

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 DocumentRight 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(&quot;%s&quot;,WORD); //stores users word //loop to convert word to all uppercase for comparison for (i=0;i&lt;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&lt;=n;a++) { if(WORD[a] == WORD[n-1]){ n--;} else { printf(&quot;\n\n%s is not a palindrome&quot;,WORD); return (0); } } printf(&quot;\n\n%s is a palindrome&quot;,WORD); return (0); }...
View Full Document

Page1 / 2

Homework6-1 - fflush(stdin);...

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

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