<html> <head> <script> function min_num() { var f_num = parseInt(document.getElementById('f_txt').value); var s_num = parseInt(document.getElementById('s_txt').value); document.getElementById('r_txt').value = Math.min(f_num, s_num); } function max_num() { var f_num = parseInt(document.getElementById('f_txt').value); var s_num = parseInt(document.getElementById('s_txt').value); document.getElementById('r_txt').value = Math.max(f_num, s_num); } function divisible() { var f_num = parseInt(document.getElementById('f_txt').value); var s_num = parseInt(document.getElementById('s_txt').value); if (f_num % s_num == 0) document.getElementById('r_txt').value = "Divisible"; else document.getElementById('r_txt').value = "Not Divisible"; } function power()...
<html> <head> <script> function square(num) { var result = parseInt(num * num); document.write("Square of " + num + " is " + result); } </script> </head> <body> <script> var n = parseInt(prompt("Enter an integer")); square(n); </script> </body> </html> <html> <head> <script> function square(num) { var result = parseInt(num * num); document.write("Square of " + num + " is " + result); } </script>...
<html> <body> <script> var sum = 0; for (i = 0; i <= 8; i++) { if (i % 2 == 0) sum = parseInt(sum + i); } document.write("Sum of first five even numbers is " + sum); //It will only add first five even numbers independent of range of loop /*var sum = 0, count = 0; for (i = 0; i...
<html> <body> <script> var n1, n2, n3; n1 = parseInt(prompt("Enter the first number")); n2 = parseInt(prompt("Enter the second number")); n3 = parseInt(prompt("Enter the third number")); /* Using Conditional Operator (n1 > n2 && n1 > n3) ? document.write(n1 + " is greatest number") : (n2 > n3 && n2 > n1) ? document.write(n2 + " is greatest number") : document.write(n3 + " is...
<html> <body> <script> var dt = new Date(); var day = dt.getDate(); var month = dt.getMonth() + 1; //January is 0 var year = dt.getFullYear(); var hour = dt.getHours(); var minute = dt.getMinutes(); var second = dt.getSeconds(); if (month < 10) month = "0" + month; var new_date = day + "/" + month + "/" + year + " " + hour...
<html> <body> <script> var sum = 0, i = 1; while(i<=20) { sum = parseInt(sum + i); i++; } document.write("Sum of numbers between 1- 20 is " + sum); </script> </body> </html> <html> <body> <script> var sum = 0, i = 1; while(i<=20) { sum = parseInt(sum + i); i++; } document.write("Sum of numbers between 1- 20 is " + sum); </script> </body>...
<html> <head> <script> function armstrong(num) { var temp = parseInt(num); var sum = 0; var remainder; while (temp > 0) { remainder = parseInt(temp % 10); sum = parseInt(sum + remainder * remainder * remainder); temp = parseInt(temp / 10); } if (num == sum) document.write(num + "<br />"); } </script> </head> <body> <script> for (i = 1; i < 500; i++) {...