Computer Science, asked by himanshutripathi9, 8 months ago

write a program to input to double type number and by using suitable mathematical function. print the maximum and minimum numbers out of the two numbers​

Answers

Answered by Anonymous
6

Answer:

import java.util.Scanner; import java.util.concurrent.Semaphore; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * * Java program to calculate Maximum and minimum of two numbers entered by user in console. * * @author Javin Paul */ public class MaxMinExerciseInJava { public static void main(String args[]) throws InterruptedException { Scanner scnr = new Scanner(System.in); // Calculating Maximum two numbers in Java System.out.println("Please enter two numbers to find maximum of two"); int a = scnr.nextInt(); int b = scnr.nextInt(); if (a > b) { System.out.printf("Between %d and %d, maximum is %d %n", a, b, a); } else { System.out.printf("Between %d and %d, maximum number is %d %n", a, b, b); } int max = Math.max(a, b); System.out.printf("Maximum value of %d and %d using Math.max() is %d %n", a, b, max); // Calculating Minimum between two numbers in Java System.out.println("Please enter two numbers to find minimum of two"); int x = scnr.nextInt(); int y = scnr.nextInt(); if (x < y) { System.out.printf("Between %d and %d, Minimum Number is %d %n", x, y, x); } else { System.out.printf("Between %d and %d, Minimum is %d %n", x, y, y); } int min = Math.min(x, y); System.out.printf("Maximum value of %d and %d using Math.min() is %d %n", x, y, min); } } Output Please enter two numbers to find maximum of two 10 11 Between 10 and 11, maximum number is 11 Maximum value of 10 and 11 using Math.max() is 11 Please enter two numbers to find minimum of two 45 32 Between 45 and 32, Minimum is 32 Maximum value of 45 and 32 using Math.min() is 32

Read more: https://www.java67.com/2015/07/java-program-to-calculate-maximum-and-minimum.html#ixzz6WQ393uIk

Answered by papyabolpur
0

Answer:

#include(stdio.h)

void main(){

int a, b, max,min;

printf( " the first no is - ") ;

scanf ( "%d", &a);

printf( " the second number is-") ;

scanf( " %d", &b) ;

if ( a > b) {

printf ( " the max is", %d , &a)

else printf ( " the max is", %d , &b)

}

}

the programme is written in c language.

Similar questions