JAVASCRIPT PROGRAM TO FIND SQUARE,CUBE,SQUARE ROOT,COMPLIMENT

<html>
<head>
<title>
program to print square,cube,square root,compliment using JAVASCRIPT
</title>
</head>
<body>
<script language="javascript">
var i,j,k,l,c;
var n = prompt("How many terms you want");
document.write("<pre>"+"i            "+"i*i              "+"i*i*i             "+"SQRT           "+"COMPLIMENT"+"</pre>");
for (i=1;i<=n;i++)
{
var k=Math.round(Math.sqrt(i));
document.write("<pre>"+i+"             "+i*i+"                "+i*i*i+"                "+k+"               "+(-i)+"</pre>");
}
</script>
</body>
</html>

OUTPUT:

No comments:

Post a Comment