INDEX
[Link] List of programs [Link].
1 Design the following static web pages required for an online book store 1-8
web site.
1) HOME PAGE: The static home page must contain three frames.
2) LOGIN PAGE
3) CATOLOGUE PAGE: The catalogue page should contain the
details of all the books available in the web site in a table.
4) REGISTRATION PAGE
2 Write JavaScript to validate the following fields of the Registration 9-14
page.
1. First Name (Name should contains alphabets and the length
should not be less than 6 characters).
2. Password (Password should not be less than 6 characters length).
3. E-mail id (should not contain any invalid and must follow the
standard pattern name@[Link])
4. Mobile Number (Phone number should contain 10 digits only).
5. Last Name and Address (should not be Empty).
3 Develop and demonstrate the usage of inline, internal and external 15-17
style sheet using CSS
4 Develop and demonstrate JavaScript with POP-UP boxes and 18-21
functions for the following problems:
a) Input: Click on Display Date button using onclick( ) function
Output: Display date in the textbox
b) Input: A number n obtained using prompt
Output: Factorial of n number using alert
c) Input: A number n obtained using prompt
Output: A multiplication table of numbers from 1 to 10 of n using
alert
d) Input: A number n obtained using prompt and add another number
using confirm
Output: Sum of the entire n numbers using alert
5 Write an HTML page that contains a selection box with a list of 5 22
countries. When the user selects a country, its capital should be
printed next in the list. Add CSS to customize the properties of the
font of the capital (color, bold and font size).
6 Write an HTML page including any required JavaScript that takes a 23-24
number from text field in the range of 0 to 999 and shows it in words.
It should not accept four and above digits, alphabets and special
characters.
Develop and demonstrate PHP Script for the following problems: 25-26
7 a) Write a PHP Script to find out the Sum of the Individual Digits.
b) Write a PHP Script to check whether the given number
is Palindrome or not
WEEK 1:
Design the following static web pages required for an online book store web site.
1) HOME PAGE: The static home page must contain three frames.
2) LOGIN PAGE
3) CATOLOGUE PAGE: The catalogue page should contain the details of all the books
available in the web site in a table.
4) REGISTRATION PAGE
Aim: Design the following static web pages required for online book store.
1. Home page:- the static home page must contains three pages
2. Top frame:- logo and college name and links to homepage, login page, registration page
and catalogue page
3. Left frame:- at least four links for navigation which will display the catalogue of
Respective links
4. Right frame:- the pages to links in the left frame must be loaded here initially it Contains
the description of the website.
DESCRIPTION: In this program the entire web paged are created by using basic HTML
tags. Home page is divided into 3 frames by using <frameset> and <frame> tags. A frame is
used to display a web page within a web page.
<frameset>:
The <frameset> tag defines a frameset.
The <frameset> element holds one or more <frame> elements.
Each <frame> element can hold a separate document.
The <frameset> element specifies HOW MANY columns or rows there will be in the
frameset, and HOW MUCH percentage/pixels of space will occupy each of them.
<frame>:
The <frame> tag defines one particular window (frame) within a <frameset>.
Each <frame> in a <frameset> can have different attributes, such as border, scrolling,
the ability to resize, etc.
PROGRAM:
[Link]:
<html>
<frameset rows="40%,*">
<frame src="[Link]" noresize scrolling="NO" name="topframe">
<frameset cols="15%,*">
<frame src="[Link]" noresize scrolling="NO" name="leftframe">
<frame src="[Link]" noresize name="rightframe" scrolling="auto">
</frameset>
</frameset>
</html>
[Link]:
<html>
<head>
<title>Top Frame</title>
</head>
<body bgcolor="YellowGreen ">
DEPARTMENT OF CSE Page 3
<img src="images/[Link]" width="125" height="115" align="left">
<img src="images/[Link]" width="125" height="115" align="right">
<center>
<marquee bgcolor="yellow" width="650" behavior="alternate">
<font face="Brush Script MT" size="8" color="green"><b><i>Online Book Store</i></b>
</font>
</marquee> <br>
<font face="Brush Script" size="6" color="white"><b>Created & Maintained By
IIIT-Ongole</b></font>
</center>
<br>
<table width="100%" height="50%" cellspacing=10>
<tr align="center">
<td> <a href="[Link]" target="_parent"><font face="Brush Script" size="6"
color="navy">HOME </a> </td>
<td> <a href="[Link]" target="rightframe"><font face="Brush Script" size="6"
color="navy">LOGIN</a> </td>
<td> <a href="[Link]" target="rightframe"> <font face="Brush Script"
size="6" color="navy">REGISTER </a> </td>
<td> <a href="[Link]" target="rightframe"> <font face="Brush Script"
size="6" color="navy">CATALOGUE</a> </td>
</tr>
</table>
</body>
</html>
[Link]:
<html>
<body align="center" bgcolor="bisque"> <br>
<a href="[Link]" target="rightframe"><font size="6">CSE</font></a><br><br>
<a href="[Link]" target="rightframe"><font size="6">ECE</font></a><br><br>
<a href="[Link]" target="rightframe"><font size="6">EEE</font></a><br><br>
<a href="[Link]" target="rightframe"><font size="6">MECH</font></a><br>
</body>
</html>
[Link]:
<html>
<body bgcolor="orange">
<center>
<img src="images/[Link]" height="170"><br>
<font face="Brush Script MT" size="5" color="blue">
<h1><b>Welcome to the Online Book Store!!!</b></font><br />
<font face="Brush Script MT" size="5" color="red">
<h2><b> "A Huge Collection Of Engineering E-Books"</b></h2></font>
</center>
</body>
</html>
DEPARTMENT OF CSE Page 4
[Link]:
<html>
<head><title>CSE</title></head>
<body bgcolor="cyan">
<center><font color="blue"><h1>Computer Science and Engineering</h1></font></center>
<br>
<table align="center">
<tr>
<td>Text Books</td>
<td>
<select >
<option value="select the book" selected>Select the book
<option value="C&Ds">C&Ds
<option value="Ads">Ads
<option value="Java">Java
<option value="Oracle">Oracle
<option value="Ms SQL Server">Ms SQL Server
<option value="MySql">MySql
</select>
</td></tr>
<tr>
<td>Quantity</td>
<td><input type="text" id="q"></td>
</tr>
<tr>
<td></td>
<td>
<form method=post action="[Link]">
<input type="submit" value=ok />
</form>
</td>
</tr>
</table>
<center>
<pre> Cost of one book is"500" + shipping "100" </pre>
</center>
</body>
</html>
[Link]:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ul>
<li>Digital Circuits</li> <li>Signals and Systems</li> <li>Digital Communication</li>
</ul>
</h2>
</body>
</html>
DEPARTMENT OF CSE Page 5
[Link]:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electrical and Electronics Engineering</font></h1>
<h2>
<ul type="square">
<li>Concepts in Electric Circuits</li>
<li>Introduction to Electronic Engineering</li>
<li>Electrical Power</li>
</ul>
</h2>
</body>
</html>
[Link]:
<html>
<body bgcolor="Plum">
<h1><font color="blue">Electronics and Communication Engineering</font></h1>
<h2>
<ol type="I">
<li>Theory of Machines</li>
<li>Automation and Robotics</li>
<li>Engineering Fluid Mechanics</li>
</ol>
</h2>
</body>
</html>
[Link]:
<html>
<head>
<title> Catalogue </title>
</head>
<body bgcolor="pink">
<form action="[Link]">
<table border="1" width="100%">
<tr>
<td>
<img src="images/[Link]" width=100 height=100/>
</td>
<td> Book: Web Technologies <br> Author: Uttam K. Roy <br> Publication:Oxford
University Press</td> <td>531 </td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
<tr>
<td> <img src="images/[Link]" width=100 height=100/></td>
<td> Book: PHP & MySQL Web Development <br> Author:Luke Welling & Laura
Thompson <br> Publication:PEARSON</td> <td> 898 </td>
<td> <input type="submit" value="Add to cart"/></td> </tr>
</table> </form>
</body> </html>
DEPARTMENT OF CSE Page 6
[Link]:
<html>
<body bg color="pink">
<basefont face="Cambria" size="4"> <br>
<center>
<img src="images/[Link]" width="385" height="135" /><br />
<font face="Brush Script MT" size="7" color="purple">
<b>Enter Login Details:</b>
</font>
</center>
<form name="f1" method="post" action="[Link]">
<table align="center" width="100" height="150" cellspacing=”15”>
<tr><td><b>Login ID:</b></td>
<td><input type="text" name="t1"></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><input type="password" name="t2"></td>
</tr>
<tr align="center">
<td><input type="submit" name="b1" value="Submit"></td>
<td><input type="reset" name="b2" value="Reset"></td>
</tr>
</table> </form> </basefont> </body> </html>
[Link]:
<html>
<head><title>Registration Form</title></head>
<body bgcolor="#E4F0F8">
<center><font color="blue" size="6" face="arial">Registration Form</font></center><br />
<form action="[Link]">
First Name(Minimum 6 characters)<font color="red">* </font>
<input type='text' id='firstname' /><br /><br />
Last Name<font color="red"><font color="red">* </font> </font>
<input type='text' id='lastname' /><br /><br />
EmailAddress<font color="red">* </font>
<input type='text' id='email' /><br />
<font color="red">(one e-mail id only):</font>
<font color="redblue">e.g. smith@[Link]</font><br /><br/>
Password(minimum 6 characters)<font color="red">* </font>
<input type='password' id='pass'><br /><br/>
Address<font color="red">* </font>
<textarea rows="2" cols="20" id='addr' /></textarea> <br /> <br/>
Mobile No<font color="red">* </font>
<input type='text' id='mobileno' /><br />
Gender: <input type='radio' name="gender">male
<input type='radio' name="gender">female<br/><br />
<input type='Submit' value='submit' />
<input type='Reset' value='reset' />
</form> </body> </html>
DEPARTMENT OF CSE Page 7
[Link]:
<html>
<head><title>order conformation</title></head>
<body bgcolor="cyan">
<center>
<pre><strong>
<b>Your order Is Conformed
</strong></pre>
<h2><b>THANK YOU...Visit Again</h2>
</center>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE Page 8
DEPARTMENT OF CSE Page 9
EXERCISE:
1. Create your class time table in a webpage.
2. Design the static web pages required for an online shopping cart.
DEPARTMENT OF CSE Page 10
WEEK 2: Write JavaScript to validate the following fields of the Registration page.
1. First Name (Name should contains alphabets and the length should not be less than 6
characters).
2. Password (Password should not be less than 6 characters length).
3. E-mail id (should not contain any invalid and must follow the standard pattern
name@[Link])
4. Mobile Number (Phone number should contain 10 digits only).
5. Last Name and Address (should not be Empty).
AIM: To validate the fields of registration page using JavaScript
DESCRIPTION: In order to validate the fields of login and registration pages JavaScript is
used. JavaScript is programming code that can be inserted into HTML pages. JavaScript
inserted into HTML pages, can be executed by all modern web browsers. JavaScript is
mainly used for validating the elements in a form submitted by the user. This JavaScript code
can react to user events.
PROGRAM: After clicking OK button the page is redirected to [Link]
<html>
<head><title>Registration Form Validation</title></head>
<body bgcolor="#E4F0F8">
<script type='text/javascript'>
function formValidator()
{
// Make quick references to our fields
var firstname = [Link]('firstname');
var lastname = [Link]('lastname');
var email = [Link]('email');
var pass = [Link]('pass');
var addr = [Link]('addr');
var mobileno = [Link]('mobileno');
// Check each input in the order that it appears in the form!
if(notEmpty(firstname, "can not be null")){
if(isAlphabet(firstname, "Please enter only letters for your Firstname")){
if(lengthRestriction(firstname, 6)){
if(isAlphabet(lastname, "Please enter only letters for your Lastname")){
if(emailValidator(email, "Please enter a valid email address")){
if(lengthRestriction(pass, 6)){
if(isAlphanumeric(pass, "please enter Numbers and Letters Only for password")){
if(notEmpty(addr, "please enter the address")){
if(isNumeric(mobileno, "Please enter a valid mobileno")){
if(lengthRestriction1(mobileno, 10 , 10)){
return true;
} } } }
}
}
}
} } }
return false;
}
function notEmpty(elem, helperMsg){
DEPARTMENT OF CSE Page 11
if([Link] == 0){
alert(helperMsg);
[Link](); // set the focus to this input
return false;
}
return true;
}
function isNumeric(elem, helperMsg){
var numericExpression = /^[0-9]+$/;
if([Link](numericExpression)){
return true;
}else{
alert(helperMsg);
[Link]();
return false;
}
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if([Link](alphaExp)){
return true;
}else
{ alert(helperMsg);
[Link]();
return false;
}
}
function isAlphanumeric(elem, helperMsg){
var alphaExp = /^[0-9a-zA-Z]+$/;
if([Link](alphaExp)){
return true;
}else
{ alert(helperMsg);
[Link]();
return false;
}
}
function lengthRestriction(elem, min){
var uInput = [Link];
if([Link] >= min){
return true;
}else
{ alert("Please enter minimum " +min+ " characters");
[Link]();
return false;
}
}
DEPARTMENT OF CSE Page 12
function emailValidator(elem, helperMsg)
{
DEPARTMENT OF CSE Page 13
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if([Link](emailExp))
{
return true;
}
else{
alert(helperMsg);
[Link]();
return false;
}
}
function lengthRestriction1(elem, min, max)
{
var uInput = [Link];
if([Link] >= min && [Link] <= max)
{
return true;
}
else {
alert("Please enter 10 numbers only");
[Link]();
return false;
}
}
</script>
<center><font color="blue" size="6" face="arial">Registration Form</font></center><br />
<form onsubmit='return formValidator()' action="[Link]">
First Name(Minimum 6 characters)<font color="red">* </font>
<input type='text' id='firstname' /><br /><br />
Last Name<font color="red"><font color="red">* </font> </font>
<input type='text' id='lastname' /><br /><br />
Email Address<font color="red">* </font>
<input type='text' id='email' /><br />
<font color="red">(one e-mail id only):</font>
<font color="redblue">e.g. smith@[Link]</font><br /><br/>
Password(minimum 6 characters)<font color="red">* </font>
<input type='password' id='pass'><br /><br/>
Address<font color="red">* </font>
<textarea rows="2" cols="20" id='addr' /></textarea> <br /> <br/>
Mobile No<font color="red">* </font>
<input type='text' id='mobileno' /><br />
Gender: <input type='radio' name="gender">male
<input type='radio' name="gender">female<br/><br />
<input type='Submit' value='submit' />
<input type='Reset' value='reset' />
</form>
</body>
</html>
DEPARTMENT OF CSE Page 14
OUTPUT:
DEPARTMENT OF CSE Page 15
DEPARTMENT OF CSE Page 16
DEPARTMENT OF CSE Page 17
WEEK - 3: Develop and demonstrate the usage of inline, internal and external style
sheet using CSS.
Aim: Design a web page using CSS which includes the following:
1) Use different font styles
2) Control the repetition of image with background-repeat and no-repeat property
3) Define style for links as a: link, a: active, a: hover, a: visited
4) Add customized cursors for links.
PROGRAM:
[Link]
[Link]
{
text-align:left;
color:blue;
font-family:Cambria;
font-size:large;
text-indent:20px;
}
[Link]
{
text-align:center;
text-decoration:underline;
text-transform:uppercase;
letter-spacing:-3px;
word-spacing:20px;
font-size:larger;
}
[Link]
{
text-align:right;
color:red;
font-family:Tahoma;
font-size:15pt;
text-decoration:overline;
font-style:italic;
}
b#headline
{
color:orange;
font-size:22px;
font-family:arial;
text-decoration:underline;
}
DEPARTMENT OF CSE Page 18
[Link]
<html>
<head>
<style type="text/css">
body
{
background-image:url('images/[Link]');
background-repeat:no-repeat;
background-position:center center;
background-attachment:fixed;
background-color:pink;
}
a:link { text-decoration:none;color:orange; }
a:visited { text-decoration:none;color:red; }
a:hover { text-decoration:underline;color:blue; }
a:active { text-decoration:underline;color:purple; }
h3 { color:green; }
.c1{cursor:crosshair}
.c2{cursor:pointer}
.c3{cursor:move}
.c4{cursor:text}
.c5{cursor:wait}
.c6{cursor:help}
</style>
<link rel="stylesheet" type="text/css" href="[Link]">
</head>
<body bgcolor="cyan">
<h1 style="color:blue;text-align:center;"> CSS (Inline, Internal and External) </h1>
<p>This Paragraph is a Not Styled</p>
<p class="left">This Paragraph is Styled by class "Left"</p>
<p class="center">This Paragraph is Styled by class "Center"</p>
<p class="right">This Paragraph is Styled by class "Right"</p>
<b>This is normal Bold</b> <br>
<b id="headline">This Bold Text is Styled </b>
<h2><b><a href=" ">This is a link</a></b></h2>
<h3 class="c1">The cursor over this element is plus sign</h3>
<h3 class="c2">The cursor over this element is a pointing hand</h3>
<h3 class="c3">The cursor over this element is a grasping hand</h3>
<h3 class="c4">The cursor over this element is a I bar</h3>
<h3 class="c5">The cursor over this element is a wait</h3>
<h3 class="c6">The cursor over this element is a question mark</h3>
</html>
DEPARTMENT OF CSE Page 19
OUTPUT 1:
OUTPUT 2: background-repeat : repeat;
EXERCISE:
1. Create a rich graphical webpage using CSS (ID selector & Class Selectors).
DEPARTMENT OF CSE Page 20
WEEK - 4: Develop and demonstrate JavaScript with POP-UP boxes and functions for
the following problems:
a) Input: Click on Display Date button using onclick( ) function
Output: Display date in the textbox
b) Input: A number n obtained using prompt
Output: Factorial of n number using alert
c) Input: A number n obtained using prompt
Output: A multiplication table of numbers from 1 to 10 of n using alert
d) Input: A number n obtained using prompt and add another number using confirm
Output: Sum of the entire n numbers using alert
PROGRAM:
a) [Link]
<html>
<body>
<script>
function display(){
var x="You have clicked";
var d=new Date();
var date=[Link]();
var month=[Link]();
month++;
var year=[Link]();
[Link]("dis").value=date+"/"+month+"/"+year;
}
</script>
<form>
<input type="text" id="dis" /><br />
<input type="button" value="Display Date" onclick="display()" />
</form>
<body>
</html>
OUTPUT:
b) [Link]
<html>
<head>
<title>factorial</title>
<script language='javascript'>
DEPARTMENT OF CSE Page 21
function factorialcalc()
{
number = parseint(prompt("enter a number, i'll calculate its factorial", "whole
numbers bigger than zero, please"))
factorial = 1
for (i=1; i <= number; i++)
{
factorial = factorial * i
}
alert("the factorial of " + number + " is " + factorial)
}
</script>
</head>
<body><form name=frm>
<input type=button value='factorial' onclick="factorialcalc();">
</form>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE Page 22
c) [Link]
<html>
<head><title> Multiplication Table </title></head>
<body>
<script type="text/javascript">
<!--
var n=prompt("Enter positive value for n: "," ");
if(!isNaN(n)) {
var table="";
var number="";
for(i=1;i<=10;i++) {
number = n * i;
table += n + " * " + i + " = " + number + "\n";
}
alert(table);
}
else {
alert("Enter positive value");
n=prompt("Enter positive value for n: "," ");
}
[Link](n+" table values displayed using alert ..<br />");
// -->
</script>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE Page 23
d) sum of n [Link]
<html>
<head><title>sum of n numbers using popup boxes</title>
<script language='javascript'>
function addsum()
{
alert("you're going to give me a list of numbers. i'm going to add them together for you");
var keepgoing = true
var sumofnums = 0
while (keepgoing) {
sumofnums = sumofnums + parseint(prompt("what's the next number to add?",""))
keepgoing = confirm("add another number?")
}
alert("the sum of all your numbers is " + sumofnums)
}
</script>
</head>
<body>
<form name=frm>
<input type=button value='sum of n numbers' onclick="addsum();">
</form>
</body>
</html>
OUTPUT:
EXERCISE:
1. Write a JavaScript program to find out the Fibonacci Series.
2. Write a JavaScript program to check the given number is palindrome or not.
DEPARTMENT OF CSE Page 24
WEEK - 5:
Write an HTML page that contains a selection box with a list of 5 countries. When the
user selects a country, its capital should be printed next in the list. Add CSS to
customize the properties of the font of the capital (color,bold and font size).
<html>
<head>
<title>WT Lab manual program no. 3</title>
</head>
<style>
h1
{
color: red;
text-align: center;
}
.textbox1
{
color: blue;
font-size: 30px;
font-weight: bold;
}
</style>
<body>
<center>
<h1> Select the country name to find its capital</h1>
<form name="myform">
Select Country <select name="country" id="sbox1" onClick="myFunction()" required>
<option value=""></option>
<option value="NEW DELHI">INDIA</option>
<option value="CANBERRA">AUSTRALIA</option>
<option value="WASHINGTON D.C">AMERICA</option>
<option value="LONDON">UNITEDKINGDOM</option>
<option value="BERLIN">GERMANY</option>
</select><br><br>
Capital <input type="text" class="textbox1" id="sbox2">
</form>
</center>
<script>
function myFunction()
{ var a=[Link]("sbox1").value;
[Link]("sbox2").value=a; }
</script> </body> </html>
OUTPUT:
DEPARTMENT OF CSE Page 25
Week - 6:
Write an HTML page including any required JavaScript that takes a number from text
field in the range of 0 to 999 and shows it in words. It should not accept four and above
digits, alphabets and special characters.
AIM: To convert number to words using JavaScript
PROGRAM:
[Link]
<html>
<head>
<title>HTML - Convert numbers to words using JavaScript</title>
<SCRIPT language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = ([Link]) ? [Link] : [Link];
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
//-->
</SCRIPT>
<script>
function NumToWord(inputNumber, outputControl)
{
var str = new String(inputNumber)
var splt = [Link]("");
var rev = [Link]();
var once = ['Zero', ' One', ' Two', ' Three', ' Four', ' Five', ' Six', ' Seven', ' Eight', ' Nine'];
var twos = ['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', '
Seventeen', ' Eighteen', ' Nineteen'];
var tens = ['', 'Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', '
Ninety'];
numLength = [Link];
var word = new Array();
var j = 0;
for (i = 0; i < numLength; i++) {
switch (i) {
case 0:
if ((rev[i] == 0) || (rev[i + 1] == 1))
{ word[j] = '';
}
else {
word[j] = once[rev[i]];
}
word[j] = word[j];
break;
case 1:
aboveTens();
DEPARTMENT OF CSE Page 26
break;
case 2:
if (rev[i] == 0) {
word[j] = '';
}
else if ((rev[i - 1] == 0) || (rev[i - 2] == 0)) {
word[j] = once[rev[i]] + " Hundred ";
}
else {
word[j] = once[rev[i]] + " Hundred and";
}
break;
default: break;
}
j++;
}
function aboveTens() {
if (rev[i] == 0) { word[j] = ''; }
else if (rev[i] == 1) { word[j] = twos[rev[i - 1]]; }
else { word[j] = tens[rev[i]]; }
}
[Link]();
var finalOutput = '';
for (i = 0; i < numLength; i++) {
finalOutput = finalOutput + word[i];
}
[Link](outputControl).innerHTML = finalOutput;
}
</script>
</head>
<body>
<h1>HTML - Convert numbers to words using JavaScript</h1>
<input id="Text1" type="text" onkeypress="return isNumberKey(event)"
onkeyup="NumToWord([Link],'divDisplayWords');" maxlength="3" style="background-
color: #efefef; border: 2px solid #CCCCC; font-size: large" />
<br /> <br />
<div id="divDisplayWords" style="font-size: 30; color: Teal; font-family: Arial;">
</div>
</body>
</html>
OUTPUT:
DEPARTMENT OF CSE Page 27
WEEK - 7: Develop and demonstrate PHP Script for the following problems:
a) Write a PHP Script to find out the Sum of the Individual Digits.
b) Write a PHP Script to check whether the given number is Palindrome or not
a) Find out Sum of the individual Digits
<?php
$n=323;
$sum=0;
while($n>0)
{
$r=$n%10;
$sum+=$r;
$n=$n/10;
}
echo "sum of individual digits are: $sum";
?>
Output:
DEPARTMENT OF CSE Page 28
b) Check whether the given number is Palindrome or not
<?php
$n=323;
$t=$n;
$re
v=0
;
whi
le($
n>0
)
{
$r=$n%10;
$rev=$rev*10+$r;
$n=(int)($n/10);
}
echo "Reverse digits are: $rev <br>";
if($t==$rev)
echo "$rev is a
Palindrome"; else
echo "$rev is not a Palindrome";
?>
Output:
EXERCISE:
1. Write a PHP Script to find the factorial of a given number.
2. Write a PHP Script to find the fibonacci series of a given number.