By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

Mr program is compiling but not running correctly ... please help

P: 2
#include <stdio.h>
#include <string.h>
#define SIZE 80

int main ()
{

char word[SIZE];
int i;
int length =0;
int palindrome ;


printf("Please enter a word\n");
//printf("terminated by -1\n");
//do
// {
scanf("%s", word);
i++;
//}
//while

(word[i-1] != -1 && i < SIZE);
// length = i -1;

for (i=0; i < length/2 && palindrome == 1 ;i++)
{
if (word[i] != word[length - i - 1]) /*test if not the same */
palindrome = 0;
}


if (palindrome == 1)
printf("array is a palindrome\n");
else
printf("array is not a palindrome\n");
return 0;
}
Oct 31 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
What is it supposed to do?

What does it actually do?
Nov 1 '06 #2

P: 2
What is it supposed to do?

What does it actually do?

IT is supposd to find out if a word is a palindrome or not
Nov 1 '06 #3

Expert 100+
P: 1,510
before the for() statement you need to initialse the variables
length=strlen(word);
palindrome=1 ;
Nov 1 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.