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

  • Home
  • SEARCH
  • 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 864769
In Process

The Archive Base Latest Questions

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

Hey, so basically I have this issue, where I’m trying to put an equation

  • 0

Hey, so basically I have this issue, where I’m trying to put an equation inside of a function however it doesn’t seem to set the value to the function and instead doesn’t change it at all.

This is a predator prey simulation and I have this code inside of a for loop.

    wolves[i+1] = ((1 - wBr) * wolves[i] + I * S * rabbits[i] * wolves[i]); 
    rabbits[i+1] = (1 + rBr) * rabbits[i] - I * rabbits[i] * wolves[i];

When I execute this, it works as intended and changes the value of both of these arrays appropriately, however when I try to put it inside of a function,

    int calcRabbits(int R, int rBr, int I, int W)
{
     int x = (1 + rBr) * R - I * R * W;

    return x;
}

int calcWolves(int wBr, int W, int I, int S, int R)
{
    int x = ((1 - wBr) * W + I * S * R * R);
    return x;

}

And set the values as such

    rabbits[i+1] = calcRabbits ( rabbits[i], rBr, I, wolves[i]);
    wolves[i+1] = calcWolves(wBr, wolves[i], I, S, rabbits[i]);

The values remain the same as they were when they were initialized and it doesn’t seem to work at all, and I have no idea why. I have been at this for a good few hours and it’s probably something that I’m missing, but I can’t figure it out.

Any and all help is appreciated.

Edit: I realized the parameters were wrong, but I tried it before with the correct parameters and it still didnt work, just accidentally changed it to the wrong parameters (Compiler mouse-over was showing the old version of the parameters)

Edit2: The entire section of code is this

    days = getDays(); // Runs function to get Number of days to run the simulation for
    dayCycle = getCycle(); // Runs the function get Cycle to get the # of days to mod by

    int wolves[days]; // Creates array wolves[] the size of the amount of days
    int rabbits[days]; // Creates array rabbits [] the size of the amount of days
    wolves[0] = W; // Sets the value of the starting number of wolves
    rabbits[0] = R; // sets starting value of rabbits


    for(int i = 0; i < days; i++) // For loop runs the simulation for the number of days
    {



//        rabbits[i+1] = calcRabbits ( rabbits[i], rBr, I, wolves[i]);    

// // //This is the code to change the value of both of these using the function 

//        wolves[i+1] = calcWolves(wBr, wolves[i], I, S, rabbits[i]);



    // This is the code that works and correctly sets the value for wolves[i+1]

        wolves[i+1] = calcWolves(wBr, wolves[i], I, S, rabbits[i]);
        rabbits[i+1] = (1 + rBr) * rabbits[i] - I * rabbits[i] * wolves[i];

    }

Edit: I realized my mistake, I was putting rBr and wBr in as ints, and they were floats which were numbers that were below 1, so they were being automatically converted to be 0. Thanks sje

  • 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-15T09:32:02+00:00Added an answer on May 15, 2026 at 9:32 am

    I was using an integer as an argument for a double.

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

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
Hey, im having this issue with cakephp, bascially i have a Has And Belongs
Hey all, basically i have an empty AS3 fla file with just the following
Hey guys I'm not sure how to write this in AS3, but basically I
Hey guys I'm running into a weird issue.. Basically, a user logs into a
Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but
Hey all. Basically I have a page full of text input fields with default
Hey. I have this javascript file that I'm getting off the web and it
Hey basically Im trying to store a solution and create a vector of these.
Hey fellas, I have this weird bug, and I have no clue how to

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.