Write javascript program whether number is divisible by 5.

 

1.Write JavaScript program whether number is divisible by 5.(Accept Number From User)

<!DOCTYPE html>

<html>

<head>

<title>Check number is divisible by 5</title>

</head>

<body>

<script type="text/javascript">

var n;

n=prompt("Enter Number to check divisible by 5");

if(n%5==0)

document.write(n+" "+"Number is Divisible by 5");

else

document.write(n+" "+"Number is Not Divisible by 5");

</script>

</body>

</html>

2.Write JavaScript program whether number is divisible by 5.(Event driven program)

<!DOCTYPE html>

<html>

<head>

<title>Check number is divisible by 5</title>

<script type="text/javascript">

function test()

{

var n=f1.t1.value;

if(n%5==0)

document.write(n+" "+"Number is Divisible by 5");

else

document.write(n+" "+"Number is Not Divisible by 5");

}

</script>

</head>

<body>

<form name="f1">

Enter Number to Check:<input type="text" name="t1">

<input type="button" value="Check Number" onClick="test()">

<form>

</body>

</html>

3.Write JavaScript program whether number is divisible by 3 and 5.(Event driven program)

<!DOCTYPE html>

<html>

<head>

<title>Check number is divisible by both 3 and 5</title>

<script type="text/javascript">

function test()

{

var n;

n=prompt("Enter Number to check divisible by both 3 and 5");

if(n%3==0 && n%5==0)

document.write(n+" "+"Number is Divisible by both 3 and 5");

else

document.write(n+" "+"Number is Not Divisible by both 3 and 5");

}

</script>

</head>

<body>

<input type="button" value="Check Number" onClick="test()">

</body>

</html>

Previous
Next Post »

Please Comment and Share. ConversionConversion EmoticonEmoticon