Social Icons

banner image

java scripts programs

EVEN OR ODD
<!DOCTYPE html>
<html>
<head>
<title>
Script
</title>
<script type="text/Javascript">
document.write("Answer");
var a=prompt("Enter any no.");
if(a%2==0)
{
document.write("<br>",a,"<br>","is an even no.");
}
else
{
document.write("<br>",a,"<br>","is an odd no.");
}
</script>
<noscript>
Javascript is not Enabled
</noscript>
</head>
</html>
FACTORIAL OF A NUMBER:
<!DOCTYPE html>
<html>
<head>
<title>
Script
</title>
<script type="text/Javascript">
document.write("Factorial is");
var n=prompt("Enter any no");
var f=1;
for(var a=1;a<=n;a++)
{
f=f*a;
}
document.write("<br>",f);
</script>
<noscript>
Javascript is not Enabled
</noscript>
</head>
</html>
USE OF PRASE INT:
<!DOCTYPE html>
<html>
<head>
<title>
Script
</title>
<script type="text/Javascript">
document.write("Answer");
var a=parseInt(prompt("Hello"));
var b=parseInt(prompt("Hi"));
var c=a+b;
document.write(c);
</script>
<noscript>
Javascript is not Enabled
</noscript>
</head>
</html>
PRODUCT OF TWO NUMBERS:
<!DOCTYPE html>
<html>
<head>
<title>
Script
</title>
<script type="text/Javascript">
document.write("Enter two numbers");
var a=prompt("Enter First number");
var b=prompt("Enter Second number");
var c=a*b;
document.write("<br>",c);
</script>
<noscript>
Javascript is not Enabled
</noscript>
</head>
</html>
WAp to calculate fact, sum of 5 no.'s using functions & create two radio buttons.
<!DOCTYPE html>
<html>
<head>
<title>
Script
</title>
<script type="text/Javascript">
function FACT()
{
document.write("Factorial is");
var n=prompt("Enter any no");
var f=1;
for(var a=1;a<=n;a++)
{
f=f*a;
}
document.write("<br>",f);
};
function SUM()
{
document.write("Sum is");
var g=parseInt(prompt("Enter 1st no"));
var h=parseInt(prompt("Enter 2nd no"));
var i=parseInt(prompt("Enter 3rd no"));
var j=parseInt(prompt("Enter 4th no"));
var k=parseInt(prompt("Enter 5th no"));
var l=g+h+i+j+k;
document.write("<br>",l);
};
</script>
<body>
<form>
<input type="radio" onclick="FACT();" name="A">Factorial
<input type="radio" onclick="SUM();" name="A">Sum
</body>
<noscript>
Javascript is not Enabled
</noscript>
</head>
</html>
java scripts programs java scripts programs Reviewed by Shobhit Goel on December 02, 2015 Rating: 5

No comments:

Airtel Hackaton 2017

Powered by Blogger.