Assigment 8
Code:-
<html>
<head>
<title> Sum of digit </title>
<script>
function sum()
var no,r,sum;
no=[Link]("text1").value;
sum=0;
while(no>0)
r=no%10;
sum=sum+r;
no=parseInt(no/10);
[Link]("text2").value=("Sum of digit is "+sum);
</script>
<style>
form{
border:2px solid black;
width:200px;
height:fit-content;
Assigment 8
padding:20px;
margin:auto;
margin-top:150px;
</style>
</head>
<body style="text-align:center;">
<h2>Sum of digit</h2>
<form>
<input type="text" placeholder="Enter any no" id="text1">
<br>
<br>
<input type="text" id="text2" disabled>
<br>
<br>
<input type="button" value="Enter" onclick="sum()">
</form>
</body>
</html>
Assigment 8
Output:-