Friday, 2 November 2018

How to make a factorial calculator program using Javascript and html.

Learn to make a factorial calculator program using JavaScript and Html.
                                                  
                                                                 (2 minutes coding)


Steps to make your own factorial calculator using JavaScripts and Html.

1.  Open NOTEPAD or NOTEPAD++ in your computer .
  
2.Copy the code given below .

<!doctype html>
<html>
<head>
<script>
function fac(){

var i, n, fact;
fact=1;
n=parseInt(document.getElementById("num").value);
for(i=1; i<=n; i++)  
{
fact= fact*i;
}  
document.getElementById("ans").value= fact;
}
</script>
</head>
<body bgcolor= "black" text= "gold" alignment ="center">
<h1>FACTORIAL CALCULATOR</h1><br>
Enter Num: <input id="num" value=0 maxlength=3;>
<br>
&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp&nbsp &nbsp
<button onclick="fac()">Enter</button>
<br>

&nbsp &nbsp&nbsp &nbspResult=<input id="ans" readonly><br>
</body>
</html>


3. Now paste it in your Notepad file.



4. Now save your file with .html extension.

5. File will appear like this.



6. Now open the file in any browser except internet explorer.






No comments:

Post a Comment

DBMS NOTES UNIT 3

                                                              UNIT 3  ER (Entity Relationship) An entity-relationship model is known as an E...