Thursday, March 22, 2012

Odd numbers between 1 to 100

This javascript gives the list of odd numbers as well as the total number of odd numbers between 1 to 100.
Following is the javascript for the same :-

<html>
<head>
    <title>Odd nos betwenn 1 to 100</title>
    <script language="javascript" type="text/javascript">
    var i,count=0;
    document.write("The odd numbers between 1 to 100 are :-");
    for(i=0;i<100;i++)
    {
        if(i%2!=0)
        {
            document.write("<br />"+i);
            count++;
        }
    }
    document.write("<br />The number of odd numbers between 1 to 100 are :"+count);
    </script>
</head>
<body>
</body>
</head>
</html>

No comments:

Post a Comment