Science, asked by Discord50, 3 months ago

WAP to accept a int number and do the following
1) find the minimum and maximum of the two number​

Answers

Answered by angeljayasing200840
1

Answer:

On some rare machines where branching is expensive, the below obvious approach to find minimum can be slow as it uses branching.

/* The obvious approach to find minimum (involves branching) */

int min(int x, int y)

{

return (x < y) ? x : y

}

Explanation:

i am not sure

Answered by crpiyushbansal
0

Answer:

package com.company;

import javax.swing.text.html.MinimalHTMLWriter;

import java.util.Scanner;

public class max_min {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       int num;

       int max;

       int min;

       char c;

       max = Integer.MIN_VALUE;;

       min=Integer.MAX_VALUE;;

       do {

           System.out.println("ENTER ANY NUMBER");

           num = sc.nextInt();

           if (num > max) {

               max = num;

           }

           if (num < min) {

               min = num;

           }

           System.out.println("DO YOU WANT TO CONTINUE ?");

           c=sc.next().charAt(0);

       }while (c == 'y' || c== 'Y');

       System.out.println(max);

       System.out.println(min);

   }

}

Explanation:

Similar questions