Computer Science, asked by ijarkhan007, 4 months ago

Write a program to ask the user to input any three number. Find the Largest Number Among these three numbers.

Answers

Answered by 2602alpha
1

Answer:

printf("num3 is the greatest among three \n");

Take the three numbers and store it in the variables num1, num2 and num3 respectively.

Firstly check if the num1 is greater than num2.

If it is, then check if it is greater than num3.

If it is, then print the output as “num1 is the greatest among three”.

Answered by purveshKolhe
5

➢ Java::

import java.util.Scanner;

public class LargestNumber {

  public static void main(String args[]) {

     int A, B, C;

     Scanner sc = new Scanner(System.in);

     System.out.print("Enter three numbers: ");

     A = sc.nextInt();

     B = sc.nextInt();

     C = sc.nextInt();

     if (A >= B && A >= C)

        System.out.println(A + " is the largest number.");

     else if (B >= A && B >= C)

        System.out.println(B + " is the largest number.");

     else

        System.out.println(C + " is the largest number.");

  }

}

➢ Python::

A = int(input("Enter first number: "))

B = int(input("Enter second number: "))

C = int(input("Enter third number: "))

if (A >= B) and (A >= C):

  largest = A

elif (B >= A) and (B >= C):

  largest = B

else:

  largest = C

print("The largest number is",largest).

\sf{Logic::}

  • It takes input in three variables.
  • Using conditional statements if, elif/else if, else it checks the greatest number and prints it.

Hope it helps..♪

Similar questions