Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:48:32+00:00 2026-05-15T13:48:32+00:00

I’m trying to complete the Project Euler problem found here. For some reason my

  • 0

I’m trying to complete the Project Euler problem found here. For some reason my function that determines whether or not a given string is a palindrome thinks “989010” is a palindrome. The funny thing is, if I directly enter that string into the palindrome function, it functions correctly. Here’s my code (I’m a newb so sorry for the bad formatting!):

bool palindrome(char pal[]);

int main(){
int i = 0;
int j = 0;
int k = 0;
int numdig = 0;
int numtest = 0;

 for(i = 999; i > 99; i--){
  for(j = 999;j > 99; j--){  //for loops multiply all 3 digit numbers
   k = i * j;
   numtest = k;
   numdig = 0; //this part takes care of determining the number of digits
    while(numtest > 0){
    numdig++;
    numtest /= 10;
    }
   char string[numdig + 1];
   itoa (k,string,10);  //itoa turns an integer into a string w/ null char.
                if( palindrome(string)){
     printf("It is a palindrome: %i\n",k);
     system("pause");
     return 0;
    }
  }
 }
 return 0; 
}

    bool palindrome(char pal[]){
 int half = (sizeof(pal) - 1)/2; //this divides the string in half
 int forward = 0;                 
 int backward = sizeof(pal)-2;   

    while(forward < half && backward > 0){  //compares the charactera in the front 
  if(pal[forward] == pal[backward]){  //to the chars in the back until they
   forward++;                      //meet in the middle
   backward--;
  }
        else{
   return false;
        }
 }
 return true;
}
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:48:32+00:00Added an answer on May 15, 2026 at 1:48 pm

    The sizeof of the parameter is not the character count of the string pointed to, because the parameter, despite its declaration form, is merely a pointer but not an array. Use strlen instead and notice that it does not include the terminating \0 in its returned value (as opposed to sizeof when applied to a string array).

    The string "989010" looks like a palindrome if you only take the first 3 characters of it, "989". Since sizeof applied to a pointer yields 4 on your machine, it’s only those first three characters that are inspected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 480k
  • Answers 480k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Create a property in your header. Set it whenever you… May 16, 2026 at 6:10 am
  • Editorial Team
    Editorial Team added an answer Draggable will revert unless it encounters with a droppable element.… May 16, 2026 at 6:10 am
  • Editorial Team
    Editorial Team added an answer You can use query parameters. For example: sql.command.Parameters.AddWithValue("?UserName", username); sql.command.Parameters.AddWithValue("?Password",… May 16, 2026 at 6:10 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.