Slip 18 - A) Write a java script program to accept the value of n and display all odd numbers up to n.

Solution:


<HTML><body>
<script>
function find()
{
var sum=0;
var no=parseInt(frm.txt1.value);
for(i=1;i<=no;i++)
{
if (i%2!=0)
document.write(i+",");
}
32
}
</script>
<form name="frm">
Enter a Number:<input name="txt1" type="text" />
<input name="b1" onclick="find();" type="button" value="display" /></form>
</BODY>
</HTML>

Post a Comment

0 Comments