JAVASCRIPT

BIGTOSMALL.PHP

// program to find the largest among three numbers

// take input from the user
// const num1 = parseFloat(prompt("Enter first number: "));
// const num2 = parseFloat(prompt("Enter second number: "));
// const num3 = parseFloat(prompt("Enter third number: "));

// const largest = Math.max(num1, num2, num3);

// // display the result
// console.log("The largest number is " + largest);

// program to find the largest among three numbers

// take input from the user

document.write("<br>The largest number from -20 20 0 <br>");
const num1 = 20;
const num2 = -20;
const num3 = 0;
let largest,smallest;

// check the condition
if(num1 >= num2 && num1 >= num3) {
    largest = num1;
}
else if (num2 >= num1 && num2 >= num3) {
    largest = num2;
}
else {
    largest = num3;
}
// check the condition
if(num1 < num2 && num1 < num3) {
    smallest = num1;
}
else if (num2 < num1 && num2 < num3) {
    smallest = num2;
}
else {
    smallest = num3;
}

// display the result
document.write("The largest number is " + largest+"<br>");
document.write("The smallest number is " + smallest+"<br>");

    

FACTOR.js

// program to find the factors of an integer

// take input
document.write("<br> factors of an integer 40<br>");
const num = 40;

document.write(`The factors of ${num} is:`);
i2="";

// looping through 1 to num
for(i = 1; i <= num; i++) {

    // check if number is a factor
    if(num % i == 0) {
        i2=i2 +" "+ i;
    }
}
document.write(`<br>  ${i2} <br>`);


factorial.php


<!DOCTYPE html>
<html>
<head><title> </title></head>
<style type="text/css">
*{
    background: #d2d5d8 ;
    
}   
h1{
    display: flex;
    justify-content: center;
    align-items: center;
}
::selection{
  background-color: #dddd2a;color:black;}
</style>
<body><h1>
    <script type="text/javascript">
       

a= parseInt(prompt("Find Factorial: "));
// set factorial ans f as 1
f=1;
// if given no is positive
if(a>0)
{
    // decrementing loop
    for(i=a;i>0;i--){
        f= f * i;   
    }
    document.write(`The Factorial of ${a} is ${f}`);
}else if(a==0){
    document.write(`The Factorial of 0 is 1`);   
}
else{
    document.write(`Please Enter Unsigned No. `);
}

 </script></h1></body></html>


CALCULATOR.html

<!DOCTYPE html>  
<html>  
<head>  
<title>  
Calculator Program in JavaScript  
</title>  
 
<!-- Begins the JavaScript Code -->  
<script>  
 
// Use insert() function to insert the number in textview.  
function insert(num)   
{  
document.form1.textview.value = document.form1.textview.value + num;  
}  
 
// Use equal() function to return the result based on passed values.  
function equal()  
{  
var exp = document.form1.textview.value;  
if(exp)  
{  
document.form1.textview.value = eval(exp)  
}  
}  
 
/* Here, we create a backspace() function to remove the number at the end of the numeric series in textview. */  
function backspace()  
{  
var exp = document.form1.textview.value;  
document.form1.textview.value = exp.substring(0, exp.length - 1); /* remove the element from total length ? 1 */  
}  
 
 
</script>  
 
<!-- Start the coding for CSS -->  
<style>  
/* Create the Outer layout of the Calculator. */  
.formstyle  
{  
width: 300px;  
height: 330px;  
margin: 20px auto;  
border: 3px solid skyblue;  
border-radius: 5px;  
padding: 20px;  
text-align: center;  
background-color: grey;  
}  
 
/* Display top horizontal bar that contain some information. */  
h1 {  
    text-align: center;  
    padding: 23px;  
    background-color: skyblue;  
    color: white;  
    }  
input:hover  
{  
background-color: green;  
}  
      
*{  
margin: 0;  
padding: 0;  
}  
 
/* It is used to create the layout for calculator button. */  
.btn{  
width: 50px;  
height: 50px;  
font-size: 25px;  
margin: 2px;  
cursor: pointer;  
background-color: red;  
color: white;  
 
}  
 
/* It is used to display the numbers, operations and results. */  
.textview{  
width: 223px;  
margin: 5px;  
font-size: 25px;  
padding: 5px;  
background-color: lightgreen;  
}     
      
</style>  
</head>  
<body>  
<h1> Calculator Program in JavaScript </h1>  
 <div class= "formstyle">  
 <form name = "form1">  
 <input class= "textview" name = "textview">  
 </form>  
 <center>  
 <table >  
 <tr>   
    <td> <input class = "btn" type = "button" value = "C" onclick = "form1.textview.value = ' ' " > </td>  
    <td> <input  class = "btn" type = "button" value = "B" onclick = "backspace()" > </td>  
    <td> <input  class = "btn" type = "button" value = "/" onclick = "insert('/')" > </td>  
    <td> <input class = "btn" type = "button" value = "x" onclick = "insert('*')" > </td>  
    </tr>  
      
     <tr>   
    <td> <input class = "btn" type = "button" value = "7" onclick = "insert(7)" > </td>  
    <td> <input class = "btn" type = "button" value = "8" onclick = "insert(8)" > </td>  
    <td> <input class = "btn" type = "button" value = "9" onclick = "insert(9)" > </td>  
    <td> <input class = "btn" type = "button" value = "-" onclick = "insert('-')" > </td>  
    </tr>  
      
     <tr>   
    <td> <input class = "btn" type = "button" value = "4" onclick = "insert(4)" > </td>  
    <td> <input class = "btn" type = "button" value = "5" onclick = "insert(5)" > </td>  
    <td> <input class = "btn" type = "button" value = "6" onclick = "insert(6)" > </td>  
    <td> <input class = "btn" type = "button" value = "+" onclick = "insert('+')" > </td>  
    </tr>  
      
     <tr>   
    <td> <input class = "btn" type = "button" value = "1" onclick = "insert(1)" > </td>  
    <td> <input class = "btn" type = "button" value = "2" onclick = "insert(2)" > </td>  
    <td> <input class = "btn" type = "button" value = "3" onclick = "insert(3)" > </td>  
    <td rowspan = 5> <input class = "btn" style = "height: 110px" type = "button" value = "=" onclick = "equal()"> </td>  
    </tr>  
    <tr>  
    <td colspan = 2> <input class = "btn" style = "width: 106px" type = "button" value = "0" onclick = "insert(0)" > </td>  
    <td> <input class = "btn" type = "button" value = "." onclick = "insert('.')"> </td>  
    </tr>  
    </table>  
    </center>  
 </div>  
 </body>  
 </html> 


PROMPT.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> TAKE A NUM FIND THE FACTORIAL OF A GIVEN NO USING PROMPT</title>
</head>
<body>


    <script type="text/javascript">
       
a= parseInt(prompt("Enter The Value of A: "));
b= parseInt(prompt("Enter The Value of B: "));

document.write("The sum is "+ eval(a+b));       
document.write(`The sum is ${a}+${b}`);   



    </script>
</body>
</html>


SUM of SERIES.php

document.write("it works Sum of series 1 2 3 4 5<br>");

var sum = 0;
[1,2,3,4,5].forEach(function(number) {
  sum += number;
});

document.write("SUM= "+sum +"<br>");

SWAP.php

//JavaScript program to swap two variables
document.write("<br> swap two variables 30 and 20 <br>");
//take input from the users
let a = 20;
let b = 30;

//create a temporary variable
let temp;

//swap variables
temp = a;
a = b;
b = temp;

document.write(`The value of a after swapping: ${a} <br>`);
document.write(`The value of b after swapping: ${b} <br>`);


task 1.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> </title>
</head>
<body>
<!-- Sum of Series -->
<script src="sumofseries.js"></script>

    <!-- 3 variable Find Biggest to smallest -->
<script src="bigtosml.js"></script>   

 <!-- swapping the value -->
<script src="swap.js"></script>   

<!-- factor of a given no -->
<script src="factor.js"></script>   

</body>
</html>



Armstrong n=

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> TAKE A NUMBER  CHECK THE NO IS armstrong OR NOT</title>
</head>
<body>


<script type="text/javascript">
       
var a=parseInt(prompt("Armstrong No Checker: "));
var num = a;
power = 0;

// find the power
while(num>0){
    power = power +1;
    num = parseInt(num/10);
}

var num=a;
sum = 0;
// calculating sum
while(num>0){
    var remainder = num%10;
    sum = sum + Math.pow(remainder,power);
    num = parseInt(num/10);

}

if(a==sum){
    document.write(`Given No ${a} is Armstrong No.`);           
}
else{
    document.write(`Given No ${a} is Not a Armstrong No.`);
}






    </script>
</body>
</html>


prime no =

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> TAKE A NUM FIND THE FACTORIAL OF A GIVEN NO USING PROMPT</title>
</head>
<body>


    <script type="text/javascript">
       
a= parseInt(prompt("Prime No Checker: "));
// set count as 0
c=0
// if given no is positive
if(a>0){
    // Loop checking divisability
    for(i=1;i<=a;i++){
        if(a%i==0){
            c=c+1;
        }
    }
    // count set to 2 when it is divided by 1 and itself
    if(c==2){
        document.write(`Given No ${a} is Prime No.`);           
    }
    else{
        document.write(`Given No ${a} is Not a Prime No.`);
    }
}else if(a==0){
    document.write(`Given No ${a} is Not a Prime No.`);
}else{
    document.write(`Please Enter Unsigned No. `);
}






    </script>
</body>
</html>

Comments

Popular posts from this blog

Sahari

[[ ROYAL CAR ]] CHANGE PASSWORD - DYNAMIC BANNER - MULTIPLE IMAGE - LOGIN LOGOUT BACK BUTTON MIDDLEWARE STOP - MAIL DIRECTLY WITH FEEDBACK WITH SAVE IN SQL DB - ADMIN REPLY EXISTING MAILS - DYNAMICALLY CSS CHANGE

Linux Terminal