Web Technologies

Web Technologies 

Slip4

Q.1) Write a JavaScript Program to read a number from user, store its factors into the array and display that array. (Handle onClick Event) [Marks 30] 

Solution

Slip4.html
<hmtl>
<head>
<script>
function display()
{
var no=parseInt(prompt("Enter a number"));
var fact=new Array(10);
var j=0;
for(i=1;i<=no/2;i++)
{
    if(no%i==0)
    {
        fact[j]=i;
        j++;
    }
}
for(i=0;i<j;i++)
    document.write(fact[i]+"</br>");
}
</script>
</head>
<input type=button id=clk value="Enter Number" onclick="display()">
</html>
BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post