Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Sunday 27 August 2017

JavaScript to find largest and smallest of 5 numbers

<html>
<script type="text/javascript">
var a=parseInt(prompt("enter the first number "));
var b=parseInt(prompt("enter the second number "));
var c=parseInt(prompt("enter the third number "));
var d=parseInt(prompt("enter the fourth number "));
var e=parseInt(prompt("enter the fifth number "));
var larg=a>b?(a>c?a:c):(b>c?b:c);
var largest=larg>d?(larg>e?larg:e):(d>e?d:e);
var sml=larg<d?(larg<e?larg:e):(d<e?d:e);
document.write("your largest number is="+largest+"<br\>");
var sml1=a<b?(a<c?a:c):(b<c?b:c);
var sml=sml1<d?(sml1<e?sml1:e):(d<e?d:e);
document.write("your smallest number is="+sml);
<\script>
<\html>



No comments:

Post a Comment