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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:42:20+00:00 2026-06-18T00:42:20+00:00

The Code int cycle_length(int i, int j) { int cycleLength = 0; for (int

  • 0

The Code

int cycle_length(int i, int j) {
    int cycleLength = 0;
    for (int k = i; k <= j; k++) {
        cout << algorithm(k) << endl;
        if (algorithm(k) > cycle_length) {
            cycleLength = algorithm(k);
        }
    }
    return cycleLength;
}

ISO C++ forbids comparison between pointer and integer [-fpermissive]

I got this error in this line if ( algorithm(k) > cycle_length).

How is that, however, the same code works right in the main() ?? and what is this error mean ???

Added
algorithm is a function take an integer input and return an integer.

int algorithm(int number1) {
    int counter = 1, number = number1;
    do {
        if (number % 2 == 0) {
            number = number / 2;
            counter++;
        } else {
            number = (3 * number) + 1;
            counter++;
        }
    } while (number != 1);

    return counter;
}
  • 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-18T00:42:21+00:00Added an answer on June 18, 2026 at 12:42 am

    You are confusing the name of the function with your local variable of nearly the same name:

    int cycle_length(int i, int j)
    {
        int cycleLength
    

    Your function is called cycle_length, your variable is called cycleLength – yet you are using cycle_length further down.

    The error message is slightly strange, because the compiler doesn’t do “compare variable names with function names to see if there is one that is similar and then suggest that maybe you just typed it wrong” – it simply says “Hmm, you are comparing a function pointer [what you get from the name of a function] with an integer, that’s not on!”

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

Sidebar

Related Questions

Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new
Example code : int main() { std::vector<int> v1{1, 2, 3, 4, 5, 6, 7,
In this code: int main(int a, int b) { printf( main(int, int) works \n\n);
I have the following code: int sec = 62; string str = string.Format(Time: {0:xxx},
I have the following code: int width = 10; int height = 7; bool[,]
I have the following code: int i=1; printf((i==1)? : hello); printf( hello); And I
This is my code: int main(int argc, char *argv[]){ FILE *fp; char *tmp, *tmp2,
Consider the following code: int i = 3 << 65; I would expect that
I have next code: int main() { OwnSelect(23, FD_READ | FD_WRITE); // <---- Several
Why does this code int (*g)(int); int (*h)(char); h = g; In C, give

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.