Monday 15 April 2013

5. Write a JavaScript to generate two random numbers and find out maximum and minimum out of it.

WTAD Practical - 5
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>


WTAD practical 5

For all WTAD programs wtad-pra cticals.html
To get all programs in your inbox.Enter your email

Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT