0% found this document useful (0 votes)
36 views33 pages

WEB Final MOD 1 2 3 Changes

Uploaded by

sumer.ahmed31329
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)
36 views33 pages

WEB Final MOD 1 2 3 Changes

Uploaded by

sumer.ahmed31329
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/ 33

MODULE 01

2 Marks :

1. Define Web.
The web is a collection of software and protocols that has been installed on most, if not
all, of the computers on the internet.

2. Define Internet.
The internet is a collection of computers and other devices connected by equipment that
allows them to communicate with each other.

3. Define Browser.
A browser is a client on the web that performs HTTP GET request and retrieves the
HTML document, parses it and displays the appropriate page to the user. Ex: Internet
explorer, Mozilla Firefox, Google chrome, Netscape navigator, Opera etc.

4. Define HTML.
HTML stands for Hypertext Markup Language.
HTML is a web language. It is used to design web pages or to arrange a website’s page
layouts.

5. What are lists? What are the types of list?


A list is used to display a set of related items on web pages.
Types of lists: • Unordered list • Ordered list • Definition list

6. List the Phrase elements.


• <em> and <strong> for emphasis.
• <blockquote><cite> and <dfn> for abbreviation, acronyms and key items.
• <code><kbd>, <var> and <samp> for computer code and information.
• <address> for addresses.
8 Marks :

1. What is internet? Explain about MIME.

The Internet is a huge collection of computers connected in a communications network.

MIME: (Multipurpose Internet Mail Extensions)

Every document on the web exists in different formats. Each format has different rendering tools.
The formats of these documents are specified with MIME. A web surfer attaches MIME format
specifications along with the document. The format of MIME is type/subtype.

Ex: text/.doc, image/.gif, image/.jpeg, video/.MP3

For a text or image document the browser renders it immediately; for an audio or video the
browser has to make the help of other software like media player-these softwares are called plug-
ins or helper applications.

• When the browser receives the document from a Web server, it uses the included MIME format
specification to determine what to do with the document.

• If the content is text, for example, the MIME code tells the browser that it is text and also
indicates the kind of text it is.

• If the content is sound, the MIME code tells the browser that it is sound.

• The most common text subtypes are plain and html.

2. List out the three types of lists and explain any two with an example.

Three types of lists:

➢ Unordered lists
➢ Ordered lists
➢ Definition lists

UNORDERED LISTS:

If you want to make a list of bullet points, you write the list within the <ul> element (which
stands for unordered list). Each bullet point or line you want to write should then be contained
between opening <li> tags and closing </li> tags (the li stands for list item).should always close
the <li> element.If you want to create bulleted list, you can do so like this (home.html):
<ul>
<li>Bullet point number one</li>
<li>Bullet point number two</li>
<li>Bullet point number three</li>
</ul>
The <ul> and <li> elements can carry all the universal attributes and UI event
attributes.

ORDERED LISTS:

In an ordered list, rather than prefixing each point with a bullet point, you can use either numbers
(1, 2, 3), letters (A, B, C), or Roman numerals (i, ii, iii) to prefix the list item. An ordered list is
contained inside the <ol> element. Each item in the list should then be nested inside the <ol>
element and contained between opening <li> and closing </li> tags.

<ol>
<li>Point number one</li>
<li>Point number two</li>
<li>Point number three</li>
</ol>
Using this type attribute to select umbers letter or roman numerical in ordered list=>
The type attribute on the <ol> element enables you to change the ordering of list items from the
default of numbers.
For example, the following is an ordered list that uses small Roman numerals.
<ol type="i">
<li>Point number one</li>
<li>Point number two</li>
<li>Point number three</li>
</ol>

3. Write a detailed note on text formatting elements.

➢ The HTML element is a physical tag which displays text in bold font. If you write
anything within<b> ....</b> element, is shown in bold letters.
➢ The HTML <strong >tag displays the content in bold font and informs the browser about
its logical importance.
➢ The HTML <i>element displays the enclosed content in italic font.
➢ The HTML <em> tag emphasizes the enclosed content in italic font, with added semantic
importance.
➢ If you want to mark or highlight a text, you should write the content within
<mark>.....</mark> tags.
➢ If you write anything within <ul> .....</ul> element, is shown in underlined text
➢ Anything written within <strike>......</strike>element is displayed with strike-through. It
is a thin line which crosses the statement.
➢ If you want that each letter has the same width then you should write the content
within<tt>.....</tt> tags.
➢ Anything that puts within <del>.........</del> is displayed as deleted text.
➢ Anything that puts within <ins>.........</ins> is displayed as inserted text
➢ If you want a part of your text to be larger than the rest of the text then put it within
<big>.....</big>tags
➢ If you want a part of your text to be smaller than the rest of the text then put it within.
<small>....</small>. tags
➢ If you put the content within<sup>...</sup> element, is shown in superscript.
➢ If you put the content within<sub>...</sub> element, is shown in subscript.

4. What are the differences between HTML and HTML5?

HTML HTML5
It didn’t support audio and video without the It supports audio and video controls with the
use of flash player support. use of <audio> and <video> tag.
It uses SQL databases and application cache to
It uses cookies to store temporary data.
store offline data.
Allows JavaScript to run in the background.
Does not allow JavaScript to run in the
This is possible due to JS Web worker API in
browser.
HTML5
Vector graphics are possible in HTML with Vector graphics are additionally an integral
VML, Silver-light, Flash, etc part of HTML5 like SVG and Canvas.
It does not allow drag and drop effects. It allows drag and drop effects.
Not possible to draw shapes like circle, HTML5 allows to draw shapes like circle,
rectangle, triangle etc. rectangle, triangle etc.
It supported by all new browser like Firefox,
It works with all old browsers.
Mozilla, Chrome, Safari, etc.
Older version of HTML are less mobile
HTML5 language is more mobile friendly.
friendly.
Doctype declaration is too long and
Doctype declaration is quite simple and easy.
complicated.
Elements like <nav> < header> was not New element for web structure like nav,
present. header, footer etc., is present.
It can’t handle inaccurate syntax. It is capable of handling inaccurate syntax
10 Marks :

1. Explain in detail the structure of HTML document with example?

Html Document Structure Body:

<!DOCTYPE html>------=----1
<html lang = ”en”>-------------2
<head>---------------------------3
</head>--------------------------4
<body>--------------------------5

.
.
</body>-------------------------6
</html>--------------------------7

➢ The first construct tells the browser what type o document the web page is.
➢ The second construct is called the container & is the tag of the body which specifies the
type of language being used.
➢ html pages are divided into 2 sections:
The head and the body, the <head> element contains descriptive elements about the
document such as its title, any style sheets or JavaScript files it uses.
➢ The fourth construct indicates the closing of head tag.
➢ The body contains content of both Html element and regular texts that will be displayed
by the browser.
➢ The sixth and seventh construct indicates closing of body and head tags.

Example:
<!DOCTYPE html>
<html>
<head lang”en”>
<meta charset = ”UTF”-8>
<title>INDIAN ART AND CULTURE</title>
<link ref = ”stylesheet” href=”main.css”/>
<script.src “info.js” </script>
</head>
<body>
<h1> Main heading </h1>
--------------------------------
--------------------------------
</body>
</html>

2. Write an HTML code for a college program that makes use of an ordered and
unordered list.

Ans. <!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<title>College Program</title>

</head>

<body>

<h1>Ordered List</h1>

<ul>

<li><strong>Types of Operating Systems</strong>

<ol>

<li>Windows</li>

<li>Linux</li>
<li>macOS</li>

</ol>

</li>

<li><strong>Types of Web Browsers</strong>

<ol>

<li>Google Chrome</li>

<li>Mozilla Firefox</li>

<li>Microsoft Edge</li>

</ol>

</li>

<li><strong>Core Computer Science Subjects</strong>

<ol>

<li>Data Structures</li>

<li>Database Management System</li>

<li>Operating Systems</li>

</ol>

</li>

</ul>

</body>

</html>
3. Write an HTML code making use of the various text formatting elements.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>HTML Formatting Demo</title>
</head>
<body>
<h1>HTML Formatting Examples</h1>
<h2>Text Formatting</h2>
<p>This is <b>bold</b>, <i>italic</i>, and <u>underlined</u> text.</p>
<p>This is <strong>strong</strong>, <em>emphasized</em>,
and<mark>highlighted</mark> text.</p>
<p>This is <del>Deleted text</del> and <ins>inserted text</ins>.</p>
<p>Chemical formula: H<sub>2</sub>O</p>
<p>Mathematical expression: x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p>
<h2>Lists</h2>
<h3>Unordered List</h3>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
<h3>Ordered List</h3>
<ol>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ol>
<h2>Table</h2>
<table border="1">
<tr>
<th>Name</th>
<th>Age</th>
<th>Country</th>
</tr>
<tr>
<td>John</td>
<td>30</td>
<td>USA</td>
</tr>
<tr>
<td>Raju</td>
<td>25</td>
<td>India</td>
</tr>
</table>
</body>
</html>
MODULE 02

2 Marks :

1. What is CSS?
CSS stands for Cascading Style Sheet, which is used to define the presentation of HTML
documents. With CSS we can assign properties, colors, sizes, borders, background images,
positioning, animate elements on page etc.

2. Give the syntax of CSS with an example.


Syntax: Example:
Selector{ a{
Property1 : value1; text-decoration: none;
Property2 : value2; text-align: center;
. margin-left: 50px;
. color: white;
PropertyN : valueN; }
}

3. List the different types of CSS.


1) Inline CSS: Inline CSS contains the CSS property in the body section attached to the
element is known as inline CSS.
2) Internal or Embedded CSS: This can be used when a single HTML document must be
styled uniquely.
3) External CSS: CSS property is written in a separate file with a .css extension and
should be linked to the HTML document using a link tag.

4. List the different types of selectors in CSS.


1) Element selector
2) Class selector
3) Id selector
4) Attribute selector
5) Pseudo-element and Pseudo-class selector
5. Define GET and POST in forms.

The GET method transfers data in the URL with a query string.
The POST is an HTTP method that encodes form data in a specified format and sends it
to the server via the HTTP message body.
6. What are Frames? List its attributes.

HTML frames allow us to present documents in multiple views. Each frame tends to
perform a specific action. To set the frames in the browser window, we use the
<frameset> tag. This tag has two attributes: 1) cols 2) rows

8 Marks :

1. Explain in detail different locations of CSS.


A: 1) Inline styles:
These are the style rules placed within an HTML element via the style attribute. An inline
style only affects the element it is defined within and over writes any other style definition
for that particular element.

Example: <h2 style="font-size : 24px;"> Main Heading </h2>


<p style="color : red; font-size : 12px;"> This is a paragraph</p>
2) Internal styles / Embedded stylesheets:
These are placed within <style> element in the head section of HTML document.
Example: <head>
<style>
body{
text-align: center;
padding: 20px;
font-family: arial;
}
div{
background-color: lightpink;
}
</style>
</head>
3) External styles:
External stylesheets are placed within an external text file with .CSS extension. When you
make a change to an external style sheet, all HTML documents that refer that style sheet will
automatically use the updated version. To refer any external style sheet <a> element is used.
Example: <head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
style.css
body{
background-color: lightblue;

h1{

color : navy;

2. Explain in detail box modeling of CSS.

A: The Box Model(BOM):

It means to design a layout, an HTML elements such that a box wraps around every HTML
element.
MARGIN
BORDER
PADDING

CONTENT

Border : Property that allows us to set the style with and colour of a border and a way to
visually separate elements.

Margin : Adds spaces around an element.


Padding : Adds spaces within an element.

Example:
<!DOCTYPE html>
<html>
<head>
<title>BOX MODEL</title>
<style>
div,p{
border: dashed 1pt red;
margin: 0;
padding: 1px;
color: green;
}
</style>
</head>
<body>
<div>
<p>Hi,How are you?</p>
<p>Welcome!!</p>
</div>
</body>
</html>

If we set ,margin as 100px and padding as 0,the the output page would like this:
margin: 100px;
padding: 0;
3. With suitable HTML code, explain check boxes and radio buttons.
A: CHECK BOXES:
This form element allows us to make any number of selections at a time.
Example:
<!DOCTYPE html>
<html>
<head>
<title>CHECKBOX DEMO</title>
</head>
<body>
<form class="p" name="checkbox form">
<b>Select the Shoe brand(s) of your choice:</b><br>
<input type="checkbox" name="option1" value="puma">PUMA<br>
<input type="checkbox" name="option2" value="adidas">ADIDAS<br>
<input type="checkbox" name="option3" value="nike">NIKE<br>
<input type="checkbox" name="option4" value="reebok">REEBOK<br>
</form>
</body>
</html>
RADIO BUTTONS:
This form element allows us to make only one selections at a time.
Example:
<!DOCTYPE html>
<html>
<head>
<title>RADIO BUTTONS DEMO</title>
</head>
<body>
<form class="p" name="radio button form">
<b>Select fruit which you like the most:</b><br>
<input type="radio" name="option1" value="guava">GUAVA<br>
<input type="radio" name="option2" value="mango">MANGO<br>
<input type="radio" name="option3" value="litchi">LITCHI<br>
<input type="radio" name="option4" value="orange">ORANGE<br>
<b>Select flower which you like the most:</b><br>
<input type="radio" name="option1" value="hibiscus">HIBISCUS<br>
<input type="radio" name="option2" value="jasmine">JASMINE<br>
<input type="radio" name="option3" value="rose">ROSE<br>
<input type="radio" name="option4" value="lily">LILY<br>
</form>
</body>
</html>
10 Marks :

1. Explain in detail about different selectors available in CSS.

A: 1) ELEMENT SELECTOR:

It selects all instances of a given HTML element.


Ex: p{
color: blue;
}
div{
margin: 0;
padding: 0;
}
2) CLASS SELECTOR:

It selects elements with a specific attribute which takes the form- period(.) followed by the
class name.
Ex: CSS:
.my_class{
Font-size: 20px;
}
HTML:
<div class= "my_class" > Computer Science </div>

3) ID SELECTOR:

An id selector selects a single element with a specific attribute which takes the form- hash(#)
followed by id name.
CSS:
#my_id{
background-color: blue;
}
HTML:
<p id= "my_id" > This is a paragraph </p>
4) ATTRIBUTE SELECTOR:

It provides a way to select html elements either by the presence of an element attribute or its
value in square brackets [ ].
CSS:
<style>
[title]
{
Padding-bottom: 3px;
}
</style>

HTML:
<body>
<div>
<img src= " img.jpg" title= "At the top of Himalaya Mountain"/>
</div>
<body>

5) PSEUDO-ELEMENT AND PSEUDO-CLASS SELECTOR:

This selector selects and styles part of an element.

Ex: CSS:

p : : first-line{

font-style: bold;

}
Pseudo class selector selects elements based on their states.
Ex: a : hover{
color : red;
}
2. Write HTML code which makes use of a table and image, ordered and unordered
list to display your resume.
<!DOCTYPE html>
<html>
<head>
<title>MY RESUME</title>
</head>
<body>
<img src="profile.png" width="90px" height="90px" />
<h4>Name: Anna Williams</h4>
<h4>Address: Maple lane, Portland</h4>
<h4>Gender: Female</h4>
<h4>Phone Number: 0123456789</h4>
<h4>Email id: anna@gmail.com</h4>
<h4>Educational Qualification:</h4>
<table border="3">
<th>Examination</th>
<th>Year of Passing</th>
<th>Board</th>
<th>Percentage</th>
<tr>
<td>10<sup>th</sup></td>
<td>2014</td>
<td>SSLC</td>
<td>91%</td>
</tr>
<tr>
<td>PUC</td>
<td>2016</td>
<td>PU Board</td>
<td>85%</td>
</tr>
<tr>
<td>Degree</td>
<td>2020</td>
<td>KBNU</td>
<td>92%</td>
</tr>
</table>
<h4>Programming languages known:</h4>
<ul>
<li>C</li>
<li>C++</li>
<li>Python</li>
<li>HTML</li>
</ul>
<h4>Projects:</h4>
<ol>
<li>Student Result Management System</li>
<li>Bank Queue</li>
<li>Fault Detection</li>
</ol>
</body>
</html>
3. Write an example HTML code to explain the use of nested frames.
A: Nested frames along us to create complex layouts by embedding one frame set inside
another. This technique can be useful for dividing the screen into multiple sections, each
containing its own set of frames.
HTML CODE:
index.html
<!DOCTYPE html>
<html>
<head>
<title>NESTED FRAMESET EXAMPLE</title>
<base target="ContentFrame">
</head>
<body>
<frameset rows="30% 70%">
<frame src="top.html" name="TopFrame">
<frameset cols="20% 80%">
<frame src="menu.html" name="MenuFrame">
<frame src="content.html" name="ContentFrame">
</frameset>
</frameset>
</body>
</html>

top.html
<!DOCTYPE html>
<html>
<head>
<title>TOP FRAME</title>
</head>
<body>
<h1>Welcome to Nested Frame Example</h1>
</body>
</html>
Menu.html
<!DOCTYPE html>
<html>
<head>
<title>MENU FRAME</title>
</head>
<body>
<ul>
<li><a href="page1.html">Page1</a></li>
<li><a href="page2.html">Page2</a></li>
</ul>
</body>
</html>

Content.html
<!DOCTYPE html>
<html>
<head>
<title>CONTENT FRAME</title>
</head>
<body>
<p>Select a page from the menu to display content here.</p>
</body>
</html>
MODULE 03
2 Marks :

1. Define JavaScript.
JavaScript is a programming language that adds interactivity & dynamic features to web
pages. It is used to create complex features like interactive maps, animated graphics ,timely
content updates & database driven apps.

2. List out various JavaScript layers.


• Document Object Model (DOM)
• Event handling
• Asynchronous JavaScript and XML (AJAX)
• jQuery
• Frameworks and Libraries
• Backend Node.JS
• ES6+ features

3. Define DOM.
DOM is a W3C recommendation for handling structured documents. DOM is a set of
platform independent and language neutral API which describes how to access & manipulate
the information, stored in XHTML, HTML & JS documents.

4. Define JavaScript objects. Write its syntax with an example.


JavaScript object is a collection of properties. Objects is JS are standalone entities having
constructors, properties & methods associated with them.
Syntax: var some_object = new object_name(par1,par2,..)
Ex: var msg = new String(“hello”)
5. Define PHP.
PHP stands for Hypertext Preprocessor. PHP is an open-source server side scripting language
designed for web development. PHP code is embedded within HTML and it is mainly used
for form handling and database access.

6. What is date() object in JavaScript. Mention any four methods of date() object.
It is used for obtaining the date & time. This date & time value is based on computers local
time. Some methods of Date() object:
1. getTime() -returns the no. of milliseconds.
2. getDate() -returns the current date.
3. getHours() -returns the hour value ranging from 0-23.
4. getSeconds() -returns the seconds value ranging from 0-59.
7. Define JS events. Mention any four JS events
A JS event is an action that can be detected by JavaScript. Many of these events are initiated
by user actions but some are generated by the browser itself. Event handler is a script that gets
executed in response to these events.

Mouse Events:
onclick
onmousedown
onmouseup
Keyboard Events:
onkeydown
onkeypress
onkeyup

8 Marks :

1. In detail, explain the uses of JavaScript.

1. JavaScript can be used as an alternative to Java applets. The Java applets need to be
downloaded separately even though they are embedded in HTML.
2. JavaScript can get embedded in HTML.
3. JavaScript can be effectively used for interaction with the users.
4. The JavaScript support form elements such as button, textbox, menus and so on. Simple
web applications such as calculator, calendar can be developed using JavaScript.
5. Using Document Object Model (DOM) JavaScript can access and modify the properties
CSS (Cascading Style Sheets) and contents of XHTML document. Hence the static web
document becomes dynamic.
6. JavaScript can be used to detect the visitor's browsers and can load the page accordingly.
7. JavaScript can be used to create cookies.
8. JavaScript are used to validate the data on the web page before submitting it to the server.
2. Explain the DOM tree structure for a simple web document.

DOM is a W3C recommendation for handling structured documents. DOM is a set of platform
independent and language neutral API which describes how to access & manipulate the
information, stored in XHTML, HTML & JS documents.

The documents in DOM are represented using a tree like structure in which every element is
represented as a node. Hence the tree structure is also referred as DOM tree.

For example: Consider following XHTML document.

<html>
<head>
<title>This is My Web Page</title>
</head>
<body>
<h1>Hi</h1>
<h2>Hello</h2>
<h3>Bye</h3>
</body>
</html>

The DOM tree will be


Document

<head> <body>

<title> <h1> <h2> <h3>

“This is My Web Page” “Hi” “Hello” “Bye”

We can describe some basic terminologies used in DOM tree as follows -

1. Every element in the DOM tree is called node.


2. The topmost single node in the DOM tree is called the root.
3. Every child node must have a parent node.
4. The bottommost nodes that have no children are called leaf nodes.
5. The nodes that have the common parent are called siblings.
3. What are JS events? Lists and explain any four JS events in detail.

A JS event is an action that can be detected by JavaScript. Many of these events are initiated by
user actions but some are generated by the browser itself. Event handler is a script that gets
executed in response to these events.

Common JS events are:

1. Mouse Events:
• onmousedown: the mouse was pressed down over an element.
• onmouseup: the mouse was released over an element.
• Onclick: the mouse was clicked on an element.

2. Keyboard Events:
• onkeydown: the user is pressing a key(this happens first).
• onkeypress: the user presses a key(this happens after onkeydown).
• onkeydown: the user releases a key that was down(this happens last).

3. Form Events:
• onblur: triggered when an element has lost focus.
• onfocus: triggers when an element gets focus.
• onselect: when user selects some text.
• onsubmit: triggered when the form is submitted.

4. Frame Events:
• onload: when a document or object has been loaded.
• onunload: the document has unloaded.
• onresize: the document view was resized
• onscroll: the document view was scrolled.
4. Give the difference between Server side scripting and Client side scripting.

CLIENT SIDE SCRIPTS SERVER SIDE SCRIPTS

1. Client side scripts are executed on the Server side scripts are executed on the web
client’s browser. server.

2. Client side scripts cannot make use of the Server side scripts can make use of resources
resources. available at the server.

3.They cannot be used to connect to the They can be used to connect to the databases
databases on the web server. that reside on the web server.

4. Client side scripting can be accessible to


Server side scripts are hidden from the client.
user.

5. JavaScript code is downloaded to the client The server sends the JavaScript, but you have
and is executed here. no guarantee that the script will even execute.

6. Response from a client side script is faster as Response from a server side script is slower as
compared server side script. compared client side script.

7. They can’t access the file system that resides They can access the file system that resides at
at the web server. the web server.

8. Ex: PHP, ASP.NET nearly all programming


Ex: HTML, CSS, JavaScript.
languages including C++, java.
10 Marks :

1. With relevant example, explain the various locations of placing a JavaScript.

Location of JS:

1. Inline JavaScript:
It refers to including JS code directly within certain HTML attributes.

Example:
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<a href="JavaScript:openWindow()">More Info</a>
<input type="button" value="okay" onclick="alert('Good Morning');">
</body>
</html>

Good Morning

Okay

2. Internal / Embedded JS:


It refers to placing the JS code within a <script> element.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/JavaScript">
alert('Mail sent');
</script>
</head>
<body>
</html>
Mail sent

3. External JS:
Here the JavaScript is written in a separate file having the file extension .js

Example: Step-1: code for .js extension


myscript.js:
document.write(“Welcome”);

Step-2: HTML document


<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/JavaScript" src="myscript.js"></script>
</head>
<body></body>
</html>

Welcome

2. Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10
and output HTML text that displays the resulting values in an HTML table format.

<!DOCTYPE html>

<html>

<head>

<title>SQUARES & CUBES</title>

<style>

table,td,th{

background-color: lightpink;

border: 2px solid black;


border-collapse: collapse;

padding: 10px;

width: 33.33%;

align-items: center;

margin: auto;

</style>

<script>

document.write( "<table><tr><th colspan='3'>NUMBERS FROM 0 TO 10 WITH THEIR


SQUARES AND CUBES </th></tr>" );

document.write("<tr><td>NUMBER</td><td>SQUARE</td><td>CUBE</td></tr>" );

for( var n=0; n <= 10; n++ )

document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>"


);

document.write( "</table>" );

</script>

</head>

</html>
3. Write a PHP script to
a) print whether given number is even or odd.
b) display the following pattern:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
a)
<!DOCTYPE html>
<html>
<head>
<title>Even Odd</title>
</head>
<body>
<?php
for($i=1;$i<=10;$i++)
{
$num=$i;
printf( "<br/>");
if($num%2==1)
{
printf("Number %d is Odd",$num);
}
else
{
printf("Number %d is Even",$num);
}
}
?>
</body>
</html>
b)
<html>
<head>
<title>Pattern in PHP </title>
</head>
<body>
<?php
for ($i = 0; $i <= 5; $i++)
{
for ($j = 0; $j < $i; $j++)
{
if (($i + $j) % 2 == 0)
{
print "0";
}
else
{
print "1";
}
}
print "<br/>";
}
?>
</body>
</html>

You might also like