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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:01:16+00:00 2026-06-11T20:01:16+00:00

No code is needed, only simple math theory. Like: print enter your age read(age)

  • 0

No code is needed, only simple math theory.

Like:

  • print “enter your age”
  • read(age)
  • if age>20
  • result=”adult”
  • print”you are”
  • print(result)

I am going to attend C language classes but before that I want to learn some basics.
I need a program/algo that finds maximum and minimum of three numbers using multiple-if or nested-if.

  • 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-11T20:01:18+00:00Added an answer on June 11, 2026 at 8:01 pm

    There’s the straightforward way:

    int min(int a, int b, int c){
        if (a <= b && a <= c){
            return a;
        }
        if (b <= a && b <= c){
            return b;
        }
        if (c <= a && c <= b){
            return c;
        }
    }
    

    There’s the way with the minimum number of comparisons:

    int min(int a, int b, int c){
        if (a < b){
            if (a < c){
                return a;
            }
            else{
                return c;
            }
        }
        else{
            if (b < c){
                return b
            }
            else{
                return c;
            }
        }
    }
    

    There’s the way with the fewest lines of code, thanks to the ternary operator:

    int min(int a, int b, int c){
        return (a<b)?((a<c)?a:c):((b<c)?b:c);
    }
    

    There’s the way twalberg mentioned in the comments:

    int min(int a, int b){
        if (a <= b){return a;}
        else{return b;}
    }
    
    int min(int a, int b, int c){
        return min(min(a,b), c);
    }
    

    max can be defined in all of these ways too, replacing < with >. You can also define it in terms of min:

    int max(int a, int b, int c){
        return -min(-a, -b, -c);
    }
    

    If you don’t wish to learn how to declare functions yet, you can drop some of these straight into your main function. For example, the second method:

    //todo: translate this pseudocode into C
    print "enter three numbers"
    read(a)
    read(b)
    read(c)
    if (a < b){
        if (a < c){
            min = a;
        }
        else{
            min = c;
        }
    }
    else{
        if (b < c){
            min = b
        }
        else{
            min = c;
        }
    }
    print "the minimum value is " + min
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've wrote all the needed code to save my Activity state (a simple form
Probably a simple question but I only have Linux to test this code on
I have a simple Google map v3 with only one marker with this code:
I have some simple GWT client code that I would like to test using
which framework helps in reducing the number of lines of code needed to create
just wondering if there is a way to reduce the amount of code needed
I have a source code that is needed to be converted by creating classes,
I know inline code is preferable, but there's a bunch of code that's needed
Why the code if (dispatch_get_current_queue() == socketQueue) is needed? why can't we just use
In the code below is the initial first loop needed when creating a 2D

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.