Vous êtes sur la page 1sur 4

EXPERIMENT NO 6

1)Arithmetic operations

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=<device-width>, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<script>
function sum(x,y){
return x+y;
}
function subtract(x,y){
return x-y;
}
function prod(x,y){
return x*y;
}
function divi(x,y){
return x/y;
}
function remainder(x,y){
return x%y;
}

document.write("Sum is "+sum(5,2)+"<br>");
document.write("Subtraction is "+subtract(5,2)+"<br>");
document.write("Multiplication is "+prod(5,2)+"<br>");
document.write("Division is "+divi(5,2)+"<br>");
document.write("Remainder is "+remainder(5,2));

</script>
</body>
</html>
2)Increasing order of numbers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
const n = prompt("Enter the value of n");
const arr=new Array(n);
for(let i=0;i<n;i++){
arr[i]=prompt("Enter any number");
}
document.write("Ascending order:<br>")

for(let i=0;i<n;i++){
let min=i;
for(let j=i;j<=n-1;j++)
{
if(arr[j]<arr[min])
{
let temp=arr[min];
arr[min]=arr[j];
arr[j]=temp;
}
}
}
for(let i=0;i<n;i++){
document.write(arr[i]+"<br>")
}

</script>
</body>
</html>
3)Display using all outputs.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML="Hello World";
document.write("Hello India");
window.alert("Hello");
console.log("Hii");
window.print("Hello World");

</script>
</body>
</html>
4)Simple Interest code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
const p= prompt("Enter the principle value");
const r= prompt("Enter the rate");
const t= prompt("Enter the time");
let si=p*r*t/100;
document.write(si);
</script>
</body>
</html>

Vous aimerez peut-être aussi