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