Monday, July 25, 2011

SourceCode

SourceCode Of play with programming post
Find Addition Number:
{
var frm=document.forms["math"];
var A=Number(frm.a.value);
var B=Number(frm.b.value);

var C=A+B;

document.math.c.value=C;

}

Find Factorial Number:
{
var n= document.fact.nVal.value;
var r=1;
for(var i=n; i>0; i--)
{
r = r*i;
}

alert("The "+n+" factorial="+r);
}

Mark Caculation:
{
if(document.mark.bangla.value>=40&&document.mark.english.value>=50&&document.mark.mathematics.value>=45)
alert("You have passed.")
else
alert("You have failed.")
}

Word Counting:
{
var frm=document.forms["count1"];
var A=frm.a.value;
var B=A.split(" ");
document.count1.c.value=B.length;
}

Finding x to the power n:
{
var x= document.power.xVal.value;
var n= document.power.nVal.value;
var r=1;
for(var i=1; i<=n; i++) { r = r*x; } alert("The "+x+" to the power "+n+"="+r); }

Popular Posts