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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:19:21+00:00 2026-06-15T19:19:21+00:00

This is the question: Write the definition of a function minMax that has five

  • 0

This is the question:
Write the definition of a function minMax that has five parameters. The first three parameters are integers. The last two are set by the function to the largest and smallest of the values of the first three parameters. The function does not return a value.

The function can be used as follows:

int a = 31, b = 5, c = 19, big, small; 
minMax(a, b, c, &big, &small); /* big is now 31; small is now 5 */ 

This is my code:

void minMax(int x, int y, int z, int* big, int* small)
{
  if (x < y && x < z)

    *small = x;

  else if (y < x && y < z)

    *small = y;

  else if (z < x && z < y)

    *small = z;

  if (x > y && x > z)

    *big = x;

    else if (y > x && y > z)

    *big = y;

  else if (z > x && z > y)

    *big = z;
  }

This is the error I’m getting:

Your function did not change the value of small. Make sure you are dereferencing it in your function.

Not sure what’s wrong?

Thanks.

  • 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-15T19:19:22+00:00Added an answer on June 15, 2026 at 7:19 pm

    I see one immediate problem.

    What do you think will happen when you pass the numbers 1, 1 and 7?

    Perhaps you may want to consider the use of <= and >= rather than just < and >.

    Since that error message looks nothing like any compiler error I’ve seen before (and the code is valid syntactically), I’d suggest the message is coming from a test harness which probably:

    • sets the big/small values to numbers other than those being passed in (eg, -9999).
    • calls the function with test data (eg, 1,1,7).
    • checks the output varibales to ensure they’ve been changed to the correct values.

    In addition, it’s not the most readable code in the world (no offence intended). If you can structure your code in such a way that its intent is clear from a glance (including comments where appropriate), you’ll have hordes of future programmers singing your praises and worshiping your name 🙂

    Something like this shows the intent a little more clearly (IMNSHO) than lots of those else if constructs:

    // Populate big/small based on max/min of x, y and z.
    
    void minMax (int x, int y, int z, int *big, int *small) {
        // Set by default to x, only change if others are bigger.
    
        *big = x;
         if (y > *big)   *big = y;
         if (z > *big)   *big = z;
    
        // Same for small but with reversed comparisons.
    
        *small = x;
         if (y < *small) *small = y;
         if (z < *small) *small = z;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the question. write a program that prompts the user to input five
This is the question: Using the Right-Left rule write the C definition of a
This is a piece of code I write for this question: Entry text on
For this question, we want to avoid having to write a special query since
I don't know how to write the title for this question. The existing title
As a followup to this question , is it possible to write a single
I'm trying to write a SQL or ActiveRecord query to answer this question: Of
This is just a question on how to write my code for a COM
This stems from a previous question I asked - about a write conflict with
This is a really novice question, but I don't write C unless (err, if)

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.