Thursday, 5 December 2019

Javascript Program

Addition of two number

<html>
<head>
<script>
function add(){
var f_no,s_no,c;
f_no=Number(document.getElementById("first").value);
s_no=Number(document.getElementById("second").value);
c=f_no+ s_no;
document.getElementById("answer").value= c;
}
</script>
</head>
<body>
Enter the First number : <input id="first">
Enter the Second number: <input id="second">
<button onclick="add()">Calculate</button>
<input id="answer">
</body>
</html>

Arithmatic operation
<html>
<head>
<script>
function add(){
var f_no,s_no,c;
f_no=Number(document.getElementById("first").value);
s_no=Number(document.getElementById("second").value);
c=f_no+ s_no;
document.getElementById("answer").value= c;
}

function mul(){
var f_no,s_no,c;
f_no=Number(document.getElementById("first").value);
s_no=Number(document.getElementById("second").value);
c=f_no*s_no;
document.getElementById("answer").value= c;
}

function mod(){
var f_no,s_no,c;
f_no=Number(document.getElementById("first").value);
s_no=Number(document.getElementById("second").value);
c=f_no%s_no;
document.getElementById("answer").value= c;
}
</script>
</head>
<body>
Enter the First number : <input id="first">
Enter the Second number: <input id="second">
<button onclick="add()">Add</button>
<button onclick="mul()">mul</button>
<button onclick="mod()">mod</button>

<input id="answer">
</body>
</html>

loop
<html>
<head>
<script>


function inc(){
var f_no,s_no,c;
f_no=Number(document.getElementById("first").value);
s_no=Number(document.getElementById("second").value);

var a;
while(f_no<=s_no)

{
document.write(f_no);
document.write("<br>");
f_no++;

}
}


</script>
</head>
<body>
Enter the First number : <input id="first">
Enter the Second number: <input id="second">
<button onclick="inc()">inc</button>


<input id="answer">
</body>
</html>

Palindrome Program:

<html>
<head>
<script>
function pln()
{
var a,num,b,temp=0;

num=Number(document.getElementById("ninput").value);

b=no;
while(no>0)
{
a=no%10;
num=parseInt(num/10);
temp=temp*10+a;
}
if(temp==b)
{
alert("Palindrome number");
}
else
{
alert("Not Palindrome number");
}
}
</script>
</head>
<body>
Enter any Number: <input id="ninput">
<button onclick="pln()">Check</button></br></br>
</body>
</html>

No comments:

Post a Comment

Collaborating Computer

Collaborating Computing:  कलबोरेटिंग का अर्थ होता है , सहयोग करना | अतः  collaborating कंप्यूटिंग का अर्थ है की नेटवर्क में ऐसी कई सारी इन...