Sky File
Sky File
BCA 175
PRACTICAL FILE
10
Exp. Problem Statement Date of Signature
No. Practical
Given
10
9.
Create A Webpage Showing the Usage of Marquee
Tag Attributes.
10. Create A Webpage Displaying the Table With 4 Cells-
1st Cell Should Consist of Unordered List of Subjects
In 4th Sem, 2nd Cell Should Consist of Some Image, 3rd
Cell Should Show the Usage of Anchor Tag And 4 th
Tag Should Contain Some Text with Background
Colour as Red
11. Create A Website Which Shows the Usage of
Navigation Frames.
12.
Write An Html Code Using Frameset in Which Each
Section Contains Different Colour
13. Create A Registration Form Using Different Elements
of Form Tag.
10
21. create a web page showing the grouping in internal
style sheet?
27. WAP to show the usage of confirm box, alert box and
prompt box
28.
WAP to print the numbers from 1 to 10 using for loop
29.
WAP to show the usage of math object.
10
Q1) Write A Paragraph in Html Using Various Tags and Alignment and
Write A Quadratic Equation Using Html Tags:
Ax2 + Bx + C=0
Solution-
Code
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Practical Q1</title>
</head>
<body>
<h1 style="text-align: left;">About The Institute</h1>
<p style="text-align: right;">
<b>The Institute</b> aims to develop as a Centre of
<i>Excellence</i> for imparting technical education and
generating competent professionals with a high degree of
<strike>credibility, integrity and ethical standards</strike>.
The Institute is passionate about grooming leaders who are not
only thorough <u>professionals</u>, but also good human beings
with values and <a href="#">“sanskars”</a>.
</p>
<p style="text-align:
center;">
Ax<sup>2</sup>+Bx+C
</p>
</body>
</html>
10
Output-
10
Q2) 1. Create A Web Page Describing Yourself.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>practical</title>
</head>
<body>
<h1>About Me</h1>
<pre>Introduction</pre>
<hr>
<p>
Hello! My Name is Tariq Aziz Khan and I am <em>19</em>
ol year
d
</p>
<p>
I am currently pursing BCA and I am currently in my
<em>1<sup>st</sup></em> year
</p>
<hr>
<p>
<big>Address :</big> <br>
<small>F-287 Shaheen
Bagh Jamia
</ Nagar,<br> City,
p> Country</small>
</
body>
</
html>
10
Output :
2.
Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Font Attributes</title>
</head>
<body>
<h1>Various Font Attributes</h1>
<p style="font-weight:
bold;"> This text is
bold.
</p>
<p style="text-decoration:
underline;"> This text is
underlined.
</p>
</body>
</html>
Output :
Q3) 1. Write A Code To Display The Names Of Beverages, Dishes &
Desserts Using Unordered Lists
Code
Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Practical</title>
</head>
<body>
<h1 style="text-align: center;">Menu</h1>
<br>
<h3>Beverages</h3>
<ul>
<li>Soft drinks <ul style="list-style-type: square;">
<li>Coca cola</li>
<li>Pespi</li>
<li>Miranda</li>
<li>Sting</li>
</ul>
</li>
<h3>Dishes</h3>
<ul>
<li>Rajma Chawal</li>
<li>Chole kulche</li>
<li>Burger</li>
<li>Momos</li>
<li>Shahi Paneer</li>
</ul>
<h3>Dessert</h3>
<ul>
<li>Ice Cream</li>
<li>Gulab Jamun</li>
<li>Rasgulla</li>
<li>Pastery <ul style="list-style-type: square;">
<li>Chocolate</li>
<li>Pineapple</li>
<li>Dark Forest</li>
</ul></li>
</ul>
</body>
</html>
Output :
2.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Practical</title>
</head>
<body>
<h1 style="text-align: center;">Institute of
Innovation in Technology and Management</h1>
<h3>Available Courses</h3>
<ol>
<li type="i">BCA</li>
<li type="A">BBA</li>
<li type="I">B.Com</li>
<li type="1">B.tech</li>
</ol>
</body>
</html>
Output :
Q4) Write A Code for Creating Definition List That Shows
Beverages With Description.
Solution-
Case
Code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Practical</title>
</head>
<body>
<h1>Beverages</h1>
<dl>
<dt>Coffee</dt>
<dd>A brewed drink prepared from roasted coffee beans</dd>
<dt>Tea</dt>
<dd>An aromatic beverage prepared by pouring hot or
boiling water over cured or fresh leaves of Camellia
sinensis</dd>
<dt>Hot Chocolate</dt>
<dd>A heated drink consisting of shaved or melted
chocolate or cocoa powder, heated milk or water, and usually a
sweetener</dd>
<dt>Juice</dt>
<dd>A drink made from extracting or pressing the
natural liquid contained in fruits or vegetables</dd>
</dl>
</body>
</html>
Output :
Q5)Write An Html Code To Display The Syllabus Off Bba(Cam) V,
Clicking On Each Subject Should Open Its Description In A New
Document
Solution-
Code :
Main.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Practical</title>
</head>
<body>
<h1 style="text-align: center;">BBA(CAM) V syllabus</h1>
<h2><pre>Subjects</pre></h2>
<ol type="I">
<li><a href="FM.html">FINANCIAL MANAGEMENT</a></li>
<li><a href="CB.html">CONSUMER BEHAVIOUR</a></li>
<li><a href="MIS.html">MANAGEMENT INFORMATION SYSTEM</a></li>
<li><a href="WDD.html">WEB DESIGNING & DEVELOPMENT</a></li>
<li><a href="BPS.html">BUSINESS POLICY & STRATEGY</a></li>
</ol>
</body>
</html>
Output :
FM.html
<!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>
<h1 style="text-align: center;">Financial Management</h1>
<h4>Unit 1</h4>
<p>
<b>Financial Management :</b> Meaning, Scope,
Objectives of Financial Management – Profit
Vs. Wealth Maximization, Financial Management and other
Areas of Management, Liquidity Vs. Profitability,
Methods of Financial Management, Organization of Finance
Function
</p>
<h4>Unit 2</h4>
<p>
<b>Capital Budgeting :</b> Concept, Importance,
Appraisal Methods: Pay back period, DCF techniques,
Accounting rate of return, Capital Rationing, Concept of
Risk, Incorporation of Risk Factor, General Techniques:
Risk adjusted discount return, certainty
equivalent coefficient and Quantitative Techniques:
Sensitivity
analysis, Probability assignment, Standard
deviation, Coefficient of variation, Decision tree.
</p>
<h4>Unit 3</h4>
<p>
<b>Capital Structure :</b> Meaning, Capital
Structure and Financial Structure, Patterns of Capital
Structure,
Optimum Capital Structure, Capital Structure Theories,
Factors Determining Capital Structure, Capital Structure
Practices in India.
</p>
<h4>Unit 4</h4>
<p>
<b>Sources of Finance :</b> Classification of Sources of
Finance, Security Financing, Loan Financing, Project
Financing, Loan Syndication- Book Building, New
Financial Institutions and Instruments viz., Depositories,
Factoring, Venture Capital, Credit Rating, Commercial
Paper, Certificate of Deposit, Stock Invest, Global
Depository Receipts.
</p>
</body></html>
Output :
Q6) Write Html Code To Insert Three Images Aligned Left, Right And
Center. Also Change The Background Color To Blue And Give A
Suitable Heading To The Web Page
Solution-
Code
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Image Alignment Example</title>
</head>
<body style="background-color: blue; color: white; text-align:
center; padding: 20px;">
</body>
</html>
Output-
Q7)1.Insert An Image In A Document And Link It To Some Other
Students.
Solution
Code 1.
<html >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Linked Image Example</title>
</head>
<body>
<a href="practice2.html">
<img src="example-image.jpg" alt="Example Image">
</a>
</body>
</html>
Output –
2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Student Information Table</title>
</head>
<body>
<h1>Student Information</h1>
<table border="1">
<thead>
<tr>
<th>S.No</th>
<th>Name</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John </td>
<td>85</td>
</tr>
<tr>
<td>2</td>
<td>Jane</td>
<td>92</td>
</tr>
<tr>
<td>3</td>
<td>Robert </td>
<td>78</td>
</tr>
<tr>
<td>4</td>
<td>Brown</td>
<td>95</td>
</tr>
<tr>
<td>5</td>
<td>Wilson</td>
<td>88</td>
</tr>
</tbody>
</table>
</body>
</html>
Output-
Q8) Create A Table Using Cellpadding, Cellspacing, Colspan And
Rowspan Which Shows The Prices Of Various Cars Of Different
Brands
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Car Prices Table</title>
</head>
<body>
</body>
</html>
Output-
Q9) Create A Webpage Showing The Usage Of Marquee Tag Attributes.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Marquee Tag Example</title>
</head>
<body>
</body>
</html>
Output
Q10) Create A Webpage Displaying the Table With 4 Cells- 1 st Cell
Should Consist of Unordered List of Subjects In 4 th Sem, 2nd Cell
Should Consist of Some Image, 3 rd Cell Should Show the Usage of
Anchor Tag And 4th Tag Should Contain Some Text with Background
Colour as Red.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Webpage with Table</title>
</head>
<body>
<h1>Table Example</h1>
<table border="1">
<tr>
<!-- 1st Cell: Unordered List of Subjects -->
<td>
<h2>Subjects in 4th Sem</h2>
<ul>
<li>Web Development</li>
<li>Database Management</li>
<li>Software Engineering</li>
<li>Computer Networks</li>
</ul>
</td>
</body>
</html>
Output-
Q11) Create A Website Which Shows The Usage Of Navigation Frames.
Solution-
Co
de <File 1>
<html>
<frameset rows="15%,70%,15%", border="0">
<frameset cols="10%,90%">
<frame src="top file.html">
<frame src="middle file.html">
</frameset>
<frameset cols="10%,90%">
<frame src="left file.html">
<frame src="toprightfile.html" name="toprightframe">
</frameset>
<frame src="bottom file.html">
</frameset>
</html>
<File 2>
<html>
<body style="padding-top: 70; font-size: x-
large;background-color: deepskyblue;">
<p><h3><a href="https://iitmjp.ac.in/about-the-
institute" target="toprightframe">About
Us</a></h3></p><br>
<p><h3><a href="https://iitmjp.ac.in/about-the-
institute"
target="toprightframe">Academics</a></h3></p><br>
<p><h3><a href="https://iitmjp.ac.in/about-the-
institute"
target="toprightframe">Faculty</a></h3></p><br>
<p><h3><a href="https://iitmjp.ac.in/about-the-
institute" target="toprightfile">Naac</a></h3></p><br>
</html>
Output-
Q12) Write an Html Code Using Frameset In Which Each
Section Contains Different Color
Solution-
Code
<!DOCTYPE html>
<html>
<head>
<title>Frameset Example with Different Colors</title>
</head>
<frameset cols="33%,34%,33%">
<frame src="frame1.html" name="frame1" style="background-color: #ffcccc;">
<frame src="frame2.html" name="frame2" style="background-color: #ccffcc;">
<frame src="frame3.html" name="frame3" style="background-color: #ccccff;">
<noframes>
<body>
Your browser does not support frames. Please update your browser.
</body>
</noframes>
</frameset>
</html>
Output-
Q13) Create A Registration Form Using Different Elements Of
Form Tag.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
</head>
<body>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label for="gender">Gender:</label><br><br>
<select id="gender" name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select>
</body>
</html>
Output-
Q14) Create a webpage describing yourself using inline style sheet?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About Me</title>
</head>
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; text-align:
center; margin: 0; padding: 20px;">
</body>
</html>
Output-
Q15) Create a web page showing the grouping in internal style sheet?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grouping in Internal Style Sheet</title>
<style>
body {
font-family: Arial, sans-serif; background-
color: #f4f4f4; color: #333;
text-align: center;
margin: 0; padding:
20px;
}
h1, h2 {
color: #0066cc;
}
p{
font-size: 18px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 10px;
}
a{
text-decoration: none; color:
#0066cc; margin: 0 10px;
font-size: 20px;
}
footer {
font-size: 14px; color:
#777;
}
</style>
</head>
<body style="font-family: Arial, sans-serif; background-color: #f4f4f4; color: #333; text-align:
center; margin: 0; padding: 20px;">
</body>
</html>
Output-
Q16) Create a webpage describing about incredible India using
external style sheet?
Solution-
Code
<Html File>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Incredible India</title>
</head>
<body>
<header>
<h1>Incredible India</h1>
</header>
<div id="introduction">
<p>Welcome to the diverse and culturally rich land of India. From the majestic
Himalayas in the north to the serene beaches in the south, India offers a plethora of
experiences for every traveler.</p>
</div>
<div id="highlights">
<h2>Highlights of India</h2>
<ul>
<li>Taj Mahal - A symbol of love and architectural marvel.</li>
<li>Varanasi - The spiritual capital on the banks of the Ganges.</li>
<li>Jaipur - The Pink City known for its vibrant culture.</li>
<li>Goa - Famous for its beautiful beaches and vibrant nightlife.</li>
</ul>
</div>
<div id="culture">
<h2>Cultural Diversity</h2>
<p>India is known for its diverse cultures, languages, and traditions.
The country celebrates various festivals, each with its unique charm and significance.</p>
</div>
</body>
</html>
/* styles.css */ body {
font-family: 'Arial', sans-serif;
background-color: #f5f5f5; color:
#333;
margin: 0;
padding: 20px;
}
header {
background-color: aqua; color:
#fff;
text-align: center;
padding: 10px;
}
h1 { margin: 0;
}
section {
margin-bottom: 20px;
}
h2 {
color: #e74c3c;
}
ul {
list-style-type: none; padding:
0;
}
li {
margin-bottom: 5px;
}
footer {
text-align: center; font-
size: 14px; color: #777;
}
Output-
Q17) Create a webpage containing a background image and apply all
the background styling attribute?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Background Styling Example</title>
<style>
body {
font-family: Arial, sans-serif; background-
image: url('image.jpg'); background-color:
#f4f4f4; background-repeat: no-repeat;
background-size: cover;
background-position: center center;
background-attachment: fixed; color: #333;
margin: 0;
padding: 20px;
}
h1 {
color: #0066cc;
}
p{
font-size: 18px;
}
div {
background-color: rgba(255, 255, 255, 0.8); padding:
20px;
border-radius: 10px;
}
</style>
</head>
<body>
<h1>Welcome to My Website</h1>
<div>
<p>This is an example webpage with a background image and various background
styling attributes applied.</p>
</div>
</body>
</html>
Output-
Q18) Create a web page showing the usage of font styling attributes ?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Font Styling Example</title>
<style>
body {
font-family: 'Arial', sans-serif; background-
color: #f4f4f4; color: #333;
margin: 0;
padding: 20px;
text-align: center;
}
h1 {
color: #0066cc; font-
size: 36px; font-weight:
bold;
text-decoration: underline;
}
p{
font-size: 18px; font-
style: italic;
}
span {
font-family: 'Courier New', monospace; font-size:
20px;
color: #e74c3c; letter-
spacing: 2px;
}
strong {
font-weight: 700;
color: #27ae60;
}
em {
font-style: normal; /* Resetting to normal style */ color: #e67e22;
}
a{
text-decoration: none; color:
#3498db;
font-weight: bold;
}
</style>
</head>
<body>
</body>
</html>
Output-
Q19) Create a web page containing two paragraph 1st paragraph
should be your qualification, 2nd is your hobbies and interest. (Both
paragraphs have same heading)
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Qualifications and Hobbies</title>
<style>
body
{
font-family: 'Arial', sans-
serif; background-color:
#f4f4f4;
color: #333;
margin: 0;
padding:
20px;
text-align: center;
}
h2 {
color: #0066cc;
}
p {
font-size: 18px;
line-height: 1.6;
margin-bottom:
20px;
}
</style>
</head>
<body>
<h2>About Me</h2>
<p><strong>Qualifications:</strong></p>
<p>I have completed my High School Studis in Huamntites
Stream from DPS Greater Noida School. Additionally, I have
accomplished National Cadet Corps 'B' Certificate.</p>
<p><strong>Hobbies and Interests:</strong></p>
<p>In my free time, I enjoy exploring new technologies
and frameworks. I also love bing watching, listening soft
music, and travelling.</p>
</body>
</html>
Output-
Q20) Create a web page showing the usage of ID and class Selector?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ID and Class Selector Example</title>
<style>
body {
font-family: 'Arial', sans-serif; background-
color: #f4f4f4; color: #333;
margin: 0;
padding: 20px;
text-align: center;
}
#header {
background-color: #3498db; color:
#fff;
padding: 10px;
}
.content {
margin-top: 20px; padding:
15px; background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
}
.important-text { color:
#e74c3c; font-weight:
bold;
}
.highlighted {
background-color: #ffffcc;
}
</style>
</head>
<body>
<div id="header">
<h1>ID and Class Selector Example</h1>
</div>
<div class="content">
<p>This is a simple example demonstrating the usage of ID and ClASS selectors in CSS.</p>
<p class="important-text">The Header Section is styled using ID selector and the text
below is styled using CLASS selector.</p>
</body>
</html>
Output-
Q21) create a web page showing the grouping in internal style sheet?
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Grouping in Internal Style Sheet</title>
<style>
body
{
font-family: 'Arial', sans-
serif; background-color:
#f4f4f4;
color: #333;
margin: 0;
padding:
20px;
text-align: center;
}
h1, h2 {
color: #0066cc;
}
p {
font-size:
18px; line-
height: 1.6;
}
ul {
list-style-type:
none; padding: 0;
}
li {
margin-bottom: 10px;
}
a {
text-decoration:
none; color:
#3498db;
font-weight: bold;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
</body>
</html>
Output-
Q22) WAP In JavaScript To Display A Username By Taking The
Input From The User
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Username Display</title>
</head>
<body>
<div>
<label for="username">Enter your username: </label>
<input type="text" id="username" placeholder="Type your username here">
<button onclick="displayUsername()">Display Username</button>
<p id="output"></p>
</div>
<script>
function displayUsername() {
// Get the value entered by the user
var username = document.getElementById('username').value;
</body>
</html>
Output-
Q23) Perform The Following Operations Using JavaScript: Addition,
Subtraction, Division And Multiplication By Taking The Input From
The User.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basic Calculator</title>
</head>
<body>
<div>
<label for="num1">Enter first number: </label>
<input type="number" id="num1" placeholder="Enter a number">
<button onclick="performOperations()">Calculate</button>
<p id="addition"></p>
<p id="subtraction"></p>
<p id="multiplication"></p>
<p id="division"></p>
</div>
<script>
function performOperations() {
// Get the values entered by the user
var num1 = parseFloat(document.getElementById('num1').value); var num2 =
parseFloat(document.getElementById('num2').value);
</body>
</html>
Output-
Q24) Perform swapping of two numbers by using temporary variable.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Swapping</title>
</head>
<body>
<div>
<label for="num1">Enter the first number: </label>
<input type="number" id="num1" placeholder="Enter a number">
<p id="result"></p>
</div>
<script>
function swapNumbers() {
// Get the values entered by the user
var num1 = parseFloat(document.getElementById('num1').value); var num2 =
parseFloat(document.getElementById('num2').value);
</body>
</html>
Output-
Q25) Check whether the number entered by the user is even or odd
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Even/Odd Checker</title>
</head>
<body>
<div>
<label for="number">Enter a number: </label>
<input type="number" id="number" placeholder="Enter a number">
<button onclick="checkEvenOdd()">Check</button>
<p id="result"></p>
</div>
<script>
function checkEvenOdd() {
// Get the value entered by the user
var number = parseInt(document.getElementById('number').value);
</body>
</html>
Output-
Q26) WAP to find the greatest number among three numbers with
or without using functions.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Greatest Number Finder</title>
</head>
<body>
<div>
<label for="num1">Enter the first number: </label>
<input type="number" id="num1" placeholder="Enter a number">
<p id="result"></p>
</div>
<script>
function findGreatest() {
// Get the values entered by the user
var num1 = parseFloat(document.getElementById('num1').value); var num2 =
parseFloat(document.getElementById('num2').value); var num3 =
parseFloat(document.getElementById('num3').value);
</body>
</html>
Output-
Q27) WAP to show the usage of confirm box, alert box and prompt box.
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>JavaScript Boxes Example</title>
</head>
<body>
<script>
// Function to show an alert
box function showAlert() {
alert("This is an alert box!");
}
if (result) {
alert("You clicked OK!");
} else {
alert("You clicked Cancel!");
}
}
}
</script>
</body>
</html>
Outpu
t-
<Alert Box>
<Confirm Box>
<Prompt Box>
Q28) WAP to print the numbers from 1 to 10 using for loop
Solution-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial- scale=1.0">
<title>Print Numbers</title>
</head>
<body>
<div>
<h2>Numbers from 1 to 10:</h2>
<script>
// Use a for loop to print numbers from 1
to 10 for (var i = 1; i <= 10; i++) {
document.write(i + '<br>');
}
</script>
</div>
</body>
</html>
Output-
Q29) WAP to show the usage of math object.
Soluton-
Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Object Example</title>
</head>
<body>
<div>
<h2>Math Object Example</h2>
<p>Random number between 0 and 1: <strong
id="randomNumber"></strong></p>
<p>Square root of 25: <strong id="squareRoot"></strong></p>
<p>Rounded value of 3.75: <strong id="roundedValue"></strong></p>
<p>Maximum of 10 and 20: <strong id="maximumValue"></strong></p>
<p>Minimum of 10 and 20: <strong id="minimumValue"></strong></p>
<script>
// Random number between 0 and 1 var
randomNumber = Math.random();
document.getElementById('randomNumber').textContent =
randomNumber.toFixed(4);
// Square root of 25
var squareRoot = Math.sqrt(25);
document.getElementById('squareRoot').textContent = squareRoot;
// Maximum of 10 and 20
var maximumValue = Math.max(10, 20);
document.getElementById('maximumValue').textContent = maximumValue;
// Minimum of 10 and 20
var minimumValue = Math.min(10, 20);
document.getElementById('minimumValue').textContent = minimumValue;
</script>
</div>
</body>
</html>
Output-
Q30) WAP to show the usage of external javascript file
Solution-
Co
de
<Html File>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>External JavaScript Example</title>
<!-- Link to the external JavaScript file -->
<script src="script.js"></script>
</head>
<body>
<div>
<button onclick="showGreeting()">Show Greeting</button>
</div>
</body>
</html>
// script.js
function showGreeting() {
var greeting = "Hello, welcome to the external JavaScript
example!"; alert(greeting);
}
Output-
Q31) Write a program to show the usage of date object.
Solution
Code
<html>
<head><title>Q17 Malkeet</title>
<h1> Show Date and Time Object</h1>
</head>
<script type="text/javascript"> var
myd=new Date();
var d=myd.getDate();
var m=myd.getMonth()
+1;
var y=myd.getFullYear();
document.write("Today date is:
"+d+"/"+m+"/"+y+"<br>"); var myt=new Date();
var h=myt.getHours(); var
m=myt.getMinutes(); var
s=myt.getSeconds();
document.write("Time is: "+h+":"+m+":"+s+"<br>");
</script>
</html>
Output-
Q32) Write a program to show the usage of string object.
Solution
Code
<html>
<head><title>Q17 Malkeet</title>
</head>
<script>
var mystr="Welcome to Java Script";
document.write("String: "+mystr+"<br>");
document.write("Length:
"+mystr.length+"<br>");
document.write("Bold: "+mystr.bold()
+"<br>");
document.write("Upper Case: "+mystr.toUpperCase()
+"<br>"); document.write("Lower Case:
"+mystr.toLowerCase()+"<br>");
document.write("strike: "+mystr.strike()+"<br>");
document.write("split: "+mystr.split('to')+"<br>");
document.write("indexof: "+mystr.indexOf('Java')
+"<br>"); document.write("substr:
"+mystr.substr(3,4)+"<br>"); document.write("replace:
"+mystr.replace('to','you all
to')+"<br>");
document.write("match: "+mystr.match('HTML')+"<br>");
document.write("character at:
"+mystr.charAt(11)+"<br>"); document.write("Concat:
"+mystr.concat(' Classes')+"<br>");
document.write("Search: "+mystr.search('Script')
+"<br>");
</script>
</html>
Output-
Q33) Write a program to implement window object ?
Solution
Code
<html>
<head><title>Q17 Malkeet</title>
<style>
body{
text-align:
center; padding-
top: 20%;
}
input
{ padding:
10px;
font-size:
16px;
} cursor:
pointer;
</style>
</head>
<script>
function win_open()
{
var
mywindow=window.open("http://www.google.com","blank","heigh
t=500","wid th=500");
}
function win_close()
{
window.close();
}
</script>
</head>
<body>
<form>
<input type="button" value="openwindow"
onclick="win_open()">
<input type="button"
value="minimizewindow"
onclick="win_close()">
</form>
</body>
</html>
Output-
Q34) Write a program to implement document object
Solution
Code
<html>
<head><title>Q17 Malkeet</title></head>
<a href="important.docx">Document</a>
<script> document.bgColor="pink";
document.fgColor="red";
document.write("Hello world");
document.title="Document Object";
document.linkColor="green";
document.alinkColor="pink";
document.vlinkColor="red";
</script>
</html>
Output-