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 8758809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:38:38+00:00 2026-06-13T14:38:38+00:00

This is my code for project euler problem number 4. A palindromic number reads

  • 0

This is my code for project euler problem number 4.

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers.

However, my code won’t compile on Visual C++. It keeps saying “Access Violation.” So can someone tell me why my code doesn’t work? And if my code does work on your compiler, does it give the right answer?

#include <iostream>
#include <cmath>
int isitapalindrome(int num);

int main (void) 
{
bool pali = false;
int a, b, c, d, e = 0;
for (a = 999; a > 100; a-- ) 
{
    for (b = 999; b > 100; b--) 
    {
        c = a*b;
        pali = isitapalindrome(c);
        if (pali == true) 
        {           
            c > e? c: e;                            
            d = c;                                  
            e = c;
        }
        else continue;
    }
}
std::cout<<d<<std::endl;
system ("pause");
return 0;
}

int isitapalindrome (int num) 
{
bool isit = false;
int digits[8];
int test = num;
int i, j, palindrome = 0;

for (i = 0; test >= 0; i++) 
{           
    digits[i] = test%10;            
    test = (test -  test%10)/10;    
}
for (j = 0; i>=j; j++) 
{
    palindrome += digits[j] * 10^(i-j);
}

if(palindrome = test) 
{
    isit = true; 
}
return isit;
}
  • 1 1 Answer
  • 0 Views
  • 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-06-13T14:38:40+00:00Added an answer on June 13, 2026 at 2:38 pm

    This

    for (i = 0; test >= 0; i++)
    

    is an infinite loop because

    test = (test -  test%10)/10;
    

    will never make test negative. Replace the loop condition with test > 0.

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

Sidebar

Related Questions

In problem 4 from http://projecteuler.net/ it says: A palindromic number reads the same both
This is from project Euler, problem 2. I wrote the following seemingly innocent code:
Spoiler alert: this is related to Problem 14 from Project Euler. The following code
I have this code written for a Project Euler problem in c++: int sum
I am working on Problem 14 on Project Euler, and my code seems to
As stated in problem 37 at Project Euler : The number 3797 has an
Project Euler problem 18 asks us to find the route from top to bottom
I'm currently working on the 58 th problem from Project Euler . While my
Possible Duplicate: Need help solving Project Euler problem 200 Similar to this question Project
I've been working on Euler project problem 4 , my code works fine but

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.