WTAD Practical - 5
Write a JavaScript to generate two random numbers and find out maximum and
minimum out of it.
Write a JavaScript to generate two random numbers and find out maximum and
minimum out of it.
<HTML>
<HEAD>
<TITLE>WTAD.practical-5 @iAmLearningHere </TITLE>
</HEAD>
<script type="text/javascript">
function calculateRandom()
{
var r1=Math.floor(Math.random()*100);
var r2=Math.floor(Math.random()*100);
document.write('<br>Random No.1 : ' + r1);
document.write('<br>Random No.2 : ' + r2);
if (r1 < r2)
{
document.write('<br><br>Minimum No.:' + r1);
document.write('<br>Maximum No.:' + r2);
}
else
{
document.write('<br><br>Minimum No.:' + r2);
document.write('<br>Maximum No.:' + r1);
}
}
</script>
<BODY>
<H4> Click on button to generate two number and see which is minimum and maximum !</H4>
<FORM>
<input type="button" name="" value="Click !" onclick="calculateRandom()"/>
</FORM>
</BODY>
</HTML>
<HEAD>
<TITLE>WTAD.practical-5 @iAmLearningHere </TITLE>
</HEAD>
<script type="text/javascript">
function calculateRandom()
{
var r1=Math.floor(Math.random()*100);
var r2=Math.floor(Math.random()*100);
document.write('<br>Random No.1 : ' + r1);
document.write('<br>Random No.2 : ' + r2);
if (r1 < r2)
{
document.write('<br><br>Minimum No.:' + r1);
document.write('<br>Maximum No.:' + r2);
}
else
{
document.write('<br><br>Minimum No.:' + r2);
document.write('<br>Maximum No.:' + r1);
}
}
</script>
<BODY>
<H4> Click on button to generate two number and see which is minimum and maximum !</H4>
<FORM>
<input type="button" name="" value="Click !" onclick="calculateRandom()"/>
</FORM>
</BODY>
</HTML>
0 comments :