Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a programme to discribe maximum and minimum between 3 numbers

+26 votes
asked Oct 3, 2023 by Naveen (200 points)

8 Answers

0 votes
answered Oct 4, 2023 by Peter Minarik (86,240 points)
edited Oct 5, 2023 by Peter Minarik
What language are you after?

For the language C/C++, you can find similar examples here: https://question.onlinegdb.com/14977/how-to-write-program-greatest-number

Look at that example and try to do your own implementation.

If you get stuck, share your work so far (orange SHARE button in the code editor) and we'll be happy to help you get back on track.

Good luck!
0 votes
answered Oct 4, 2023 by MOHAMMAD TAJA (140 points)
please check if this is correct

def find_maximum(num1, num2, num3):
    return max(num1, num2, num3)

def find_minimum(num1, num2, num3):
    return min(num1, num2, num3)

num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

maximum = find_maximum(num1, num2, num3)
minimum = find_minimum(num1, num2, num3)

print("Maximum number is:", maximum)
print("Minimum number is:", minimum)
0 votes
answered Oct 5, 2023 by Sarthak Pandit (140 points)
if(a>b&&a>c)

printf("a is greater);

else if (b>c&&b>a)

printf("b is greater );

el;se

printf("c is greater);
0 votes
answered Oct 6, 2023 by ArshAgrawal21 (140 points)
take three variable input in array and then sort the array by using any sorting tech. Then the first element is the minimal element(a[0]) and the last element us the maximum element (a[1]) ;

This is how you get the max and min element in three numbers.
0 votes
answered Oct 6, 2023 by Sino (140 points)
program FindMinBetween3Numbers;
uses math;
var num1, num2, num3, ans : int64;
w : string;
begin
ans := 0;
writeln('enter first number');
readln(num1);
 writeln('enter second number');
readln(num2);
 writeln('enter three number');
readln(num3);
writeln('write "min" if you wanna find minimum and write "max" if you wanna find maximum');
readln(w);

if w = 'min' then
begin
ans:= min(min(num1, num2), num3);
writeln('the minimum between', ' ', num1, ', ', num2, ' and ', num3, ' is ', ans );
end;

if w = 'max' then
begin
ans:= max(max(num1, num2), num3);
writeln('the maximum between', ' ', num1, ', ', num2, ' and ', num3, ' is ', ans );
end;

end.
0 votes
answered Oct 6, 2023 by Gulshan Negi (1,580 points)

Well, it depends on which programming language you are looking to do this. 

For example, in Python:

# Input three numbers from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

# Find the maximum and minimum using conditional statements
maximum = num1  # Assume num1 is the maximum initially
minimum = num1  # Assume num1 is the minimum initially

# Compare with num2 and num3
if num2 > maximum:
    maximum = num2
elif num2 < minimum:
    minimum = num2

if num3 > maximum:
    maximum = num3
elif num3 < minimum:
    minimum = num3

# Display the results
print(f"The maximum number is: {maximum}")
print(f"The minimum number is: {minimum}")

Thanks

+1 vote
answered Oct 6, 2023 by Łucky (160 points)
#include <stdio.h>

int main()
{
    int a, b, c;
    printf("Enter number a : ");
    scanf("%d",&a);
    printf("Enter number b : ");
    scanf("%d",&b);
    printf("Enter number c : ");
    scanf("%d",&c);
    if(a> b && a> c){
        printf("a is max");
    }
    else if(b> a && b> c){
        printf("b is max");
    }
    else{
        printf("c is max");
    }

    return 0;
}
0 votes
answered Nov 27, 2023 by nasiya (240 points)

#include<stdio.h>

int main() {

    int i,arr[100],n,max,min;

    printf("Enter the limit:");

    scanf("%d",&n);

   

    printf("Enter the values:");

    for(i=0;i<n;i++)

    {

        scanf("%d",&arr[i]);

    }

    printf("Entered elements are:");

    for(i=0;i<n;i++)

    {

        printf("\n%d\t",arr[i]);

    }

    max = arr[0];

    min = arr[0];

    for(i=0;i<n;i++)

    {

        if(arr[i] > max)

        {

            max=arr[i];

        }

        if(arr[i] < min)

        {

            min=arr[i];

        }

    }

    printf("\nMaximum elements:%d",max);

    printf("\nMinimum elements:%d",min);

}

commented Dec 2, 2023 by Ananya K.J (300 points)
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a>=b && a>=c)
    {
        cout<<a;
    }
    else if(b>=a &&b>=c)
    {
        cout<<b;
    }
    else
    {
       cout<<c;
    }

    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...