0% found this document useful (0 votes)
42 views

Css 2

The document contains 6 programs written in JavaScript with HTML: 1. A login validation program 2. A program to find the greatest of 3 numbers 3. A program to calculate factorial using a for loop 4. A program to generate Fibonacci series using a while loop 5. A program to print numbers from 10 to 1 using a do-while loop 6. A program to check if a character is a vowel or consonant using a switch case

Uploaded by

ayush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Css 2

The document contains 6 programs written in JavaScript with HTML: 1. A login validation program 2. A program to find the greatest of 3 numbers 3. A program to calculate factorial using a for loop 4. A program to generate Fibonacci series using a while loop 5. A program to print numbers from 10 to 1 using a do-while loop 6. A program to check if a character is a vowel or consonant using a switch case

Uploaded by

ayush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Name:-Ayush Maroti Wadje Roll No:-76 Class:-CO5I

Write a program in JavaScript for Checking the username="Gramin" and


Pass="Poly".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
<script type="text/javascript">

function myLogin() {
var username = document.getElementById("username").value ;
var password = document.getElementById("password").value;
if (username=="gramin" && password=="poly") {
alert("Login Sucessful!!");
} else {
alert("Login Failed!!");
}
}
</script>
<style type="text/css">
body{
background-color: lightgrey;
text-align: center;
margin-top:20%;
}
</style>
</head>
<body>
<h1>Login</h1>
<label>username: </label><input type="text" id="username"><br><br>
<label>password: </label><input type="password" id="password"><br><br>
<input type="button" onClick="myLogin()" name="submit" value="login">
</body>
</html>

Output:-
Write a JavaScript program for finding greatest amongst 3 number.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Greatest Number</title>
<script type="text/javascript">
var num1 = 10;
var num2 = 20;
var num3 = 30;
function myFunction() {
if(num1 >= num2 && num1 >= num3) {
alert( num1 +" is Greatest number");
}
else if (num2 >= num1 && num2 >= num3) {
alert(num2 + " is Greatest number");
}
else {
alert(num3 + " is Greatest number");
}
}
</script>
</head>
<body>
<h1>Prgram to find greatest number</h1>
<button onClick="myFunction()">Click</button>
</body>
</html>
Output:-

Write a JavaScript program for finding Factorial of no using For Loop.


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
function fact() {
var i, num, f;
f = 1;
num = document.getElementById("num").value;
for(i = 1; i <= num; i++) {
f = f * i;
}
i = i - 1;
document.write(f);
}
</script>
</head>
<body>
<input type="text" name="" id="num">
<input type="button" onclick="fact()" value="Check">
</body>
</html>
Write a JavaScript program for generating Fibonacci series using while loop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fibonacci Series</title>
<script type="text/javascript">
function Fibonacci() {
var i = 0,j=1,k;
num = prompt("Enter number");
while(i<num) {
document.write(i+ "<br>");
k=i+j;
i=j;
j=k;
}
}
</script>
</head>
<body>
<input type="Button" name="" value="Click" onclick="Fibonacci()">
</body>
</html>
Write a JavaScript program for printing 10 to 1 using Do..While loop
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Print Number from 1 to 10</title>
<script type="text/javascript">
function Print() {
var i=10;
document.write("Number From 1 to 10" + "<br>")
do{
document.write(i + "<br>");
i--;

}while(i>=1)

}
</script>
</head>
<body>
<input type="Button" name="" value="Print" onclick="Print()">
</body>
</html>
Write a JavaScript program for checking the character is vowel or not using Swtich
case.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Find</title>
<script type="text/javascript">
function Check() {
var ch;
ch = document.getElementById("char").value;

switch(ch) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
document.write("It is Vowel");
break;
default:
document.write("It is consant");
}
}
</script>
</head>
<body>
<input type="text" name="" id="char">
<input type="button" onclick="Check()" value="Find">
</body>
</html>

You might also like