Computer Science, asked by shivanibhujbal6121, 7 days ago

Write an algorithm to find the smallest number in between any three numbers

Answers

Answered by adityavirajrao
1

Get three inputs num1, num2 and num3 from user using scanf statements. Check whether num1 is smaller than num2 and num3 using if statement, if it is true print num1 is smallest using printf statement. Else, num2 or num3 is smallest. So check whether num2 is smaller than num3 using elseif statement.

Answered by samarthkrv
0

Answer:

import java.util.*;

import java.lang.Math;

class Brainly

{

public static void main(String args[])

{

Scanner scanner = new Scanner(System.in);

int x,y;

ArrayList<Integer> nums = new ArrayList<Integer>();

System.out.println("Enter three numbers ");

 for(int i = 0; i < 3; i++)

 {

 x = scanner.nextInt();

 

 nums.add(x);

 }

 y = Collections.max(nums);

 System.out.println("The largest number is " + y);

}

}

Explanation:

Attachments:
Similar questions