Sei sulla pagina 1di 84

Practical 1 A

Use of basic tags – Text formatting tags

<!DOCTYPE HTML>

<HTML>

<HEAD><TITLE>FORMATTING TAGS</TITLE></HEAD>

<BODY>

<H1>WELCOME TO HTML WEBPAGE</H1>

this is <b>bold</b>text<br/>

this is <i>italics</i>text</br>

this is text with <u>underline</u><br/>

todays best offers is <strike>40%</strike> 30%<br/>

its dear,not <s>deer</s><br/>

<tt>this is type writer text</tt><br/>

<center>this text is at center of the page </center><br/>

<em>this is emphasized text</em><br/>

this text is <strong>strong emphasized text</srtong><br/>

use of subscript:H<sub>2</sub><br/>

use of superscript:X<sup>2</sup><br/>

the text is with <q>quotation</q>tag<br/>

please press <kbd>F5</kbd> for refresh<br/>


please press <kbd>prtscn</kbd> take to screenshot<br/>

use of var tag in equation:<br/>

area of a rectangle=<var>l</var>*<var>b</var><br/>

<del>this is deleted text</del><br/>

<big>this text is big</big><br/>

<small>this text is small</small><br/>

<ins>this is inserted text</ins><br/>

<cite>reverse string:</cite>

<bdo dir="rtl"> saraf college</bdo>

</body>

</html>
Practical 1 B
Block level formatting tags
<!DOCTYPE HTML>
<HTML>
<HEAD><TITLE>BLOCL LEVEL FORMATTING TAGS</TITLE></HEAD>
<BODY>
<H1>WELCOME TO HTML WEBPAGE</H1><BR/>
<H2>WELCOME TO HTML WEBPAGE</H2><BR/>
<H3>WELCOME TO HTML WEBPAGE</H3><BR/>
<H4>WELCOME TO HTML WEBPAGE</H4><BR/>
<H5>WELCOME TO HTML WEBPAGE</H5><BR/>
<H6>WELCOME TO HTML WEBPAGE</H6><BR/>
<H6>STAR PYRAMID:</H6>
<PRE>
*
* *
* * *
* * *
* * * *
</PRE>
<HR HEIGHT="3" WIDTH="90%" COLOR="RED"/>
<H5>C++ CODE TO PRINT TEXT:</H5>
<CODE>
#include<iostream.h><BR/>
void main()<BR/>
{<BR/>
Cout<<"welcome to html:";<BR/>
getch();<BR/>
}<BR/>
</code>
<h6>OUTPUT OF THE ABOVE CODE</h6>
<samp>welcome to html:</samp>
<hr color="rgb(0,0,255)/>
<h6> following sentences shows the use of blockquote</h6>
<blockquote>HTML stands for hypertext markup language .<head> tag
is the first member for the html family.
it is use to make webpages.</blockquote>
<font color="red" size="20" face="arial">
this is text with red colour with a size of 20 and font style arial.</font>
<h6>ADDRESS OF COLLEGE:</h6>
<address>G.SARAF;<BR/>
SUNDERNAGAR,<BR/>S.V.ROAD,<BR/>
MALAD(WEST)</address>
<abbr title="account=">A/C</abbr>is an abbreviation of
word<b>account</b><BR/>
<acronym title="American Standard Code for Information
interchange<BR/>
ASCII</acronym> is an acronym for American Standard Code for
Information interchange.<BR/>
<p>HTML stands for hypertext markup language .<head> tag is the first
member for the html family.
it is use to make webpages.</p><BR/>
<p align="center">HTML stands for hypertext markup language .<head>
tag is the first member for the html family.
it is use to make webpages.</p><BR/>
<p align="right">HTML stands for hypertext markup language .<head>
tag is the first member for the html family.
it is use to make webpages.</p><BR/>
<p align="left">HTML stands for hypertext markup language .<head>
tag is the first member for the html family.
it is use to make webpages.</p><BR/>
<p align="justify">HTML stands for hypertext markup language .<head>
tag is the first member for the html family.
it is use to make webpages.</p><BR/>
FOR ANY QUERY,YOU CANCONTACT US AT
</address>info@saraf college.org</address></body>
</html>
Practical 1 C
List tags
<!DOCTYPE HTML>
<html>
<head><title>LISTS TAGS</title></head>
<body bgcolor="yellow">
<center><h1><u><font face="gabriola" color="golden">DESSERT MENU
LIST</font>
</u></h1></center>
<font face="lucida calligraphy">
<ol type="I">
<li>cake</li>
<ul type="disc">
<li>chocolate banana cake</li>
<li>basic vanilla cake</li>
<li>Italian lemon cake</li>
<li>cassove cake</li>
</ul>
<li>Ice-cream</li>
<ul type="circle">
<li>chocolate malt Ice-cream</li>
<li>maxican "fried"ice cream</li>
<li>salted caramel</li>
</ul>
<li>JUICE</li>
<ul type="square">
<li>mango juice</li>
<li>orange juice</li>
<li>mix fruit juice</li>
</ul>
</ol>
<dl>
<dt>CAKE</dt>
<dd>cake is a form of sweet dessert that is typically baked.in this oldest
form of cake cover a wide range of preparation that can be a simple
cake or alobrate,and that share features with order dessert,such as
pastries ,meringues,custard and pies</dd>
<dt>ICE CREAM</dt>
<dd>Ice cream is sweetened frozen food typically eaten as a dessert.it
is usually made from milk and cream and often combines with fruits
and other ingredients and flavour.it is typically sweetened with sugar
and sugar substitutes.</dd>
<dt>JUICE</dt>
<dd>Juice is a beverage made from the the extraction or pressing out
the natural liquid contained in fruits and vegetables. it can also refer to
liquids that are flavoured with these or other biological food
sources.juices is commonly consumed as a beverage or used as an
ingredientor flavouringin foods or other beverges</dd></font>
</body>
</html>
Practical 1 D
Web navigation- creating of website
<!DOCTYPE HTML>
<head>
<title> journey</title></head>
<body>
<h1>welcome dear</h1>
<a href="Mumbai.html" target="_blank">
Mumbai</a>
<a href="Delhi.html" target="_self">
Delhi</a>
<a href="Kolkata.html" target="_parent">
Kolkata</a>
<a href="Chennai.html" target="_self">
Chennai</a>
</body>
</html>

mumbai.html
<!DOCTYPE HTML>
<head>
<title> journey</title></head>
<body>
<h1>WELCOME TO MUMBAI</h1>
<center>
<a href="p1d.html">back</a>
</center>
</body>
</html>
delhi.html
<!DOCTYPE HTML>
<head>
<title> journey</title></head>
<body>
<h1>WELCOME TO DELHI</h1>
<center>
<a href="p1d.html">back</a>
</center>
</body>
</html>
kolkata.html
<!DOCTYPE HTML>
<head>
<title> journey</title></head>
<body>
<h1>WELCOME TO KOLKATA</h1>
<center>
<a href="p1d.html">back</a>
</center>
</body>
</html>
chennai.html
<!DOCTYPE HTML>
<head>
<title> journey</title></head>
<body>
<h1>WELCOME TO CHENNAI</h1>
<center>
<a href="p1d.html">back</a>
</center>
</body>
</html>
Practical 1 E
Inline style sheet
<DOCTYPE HTML>
<html>
<head>
<title>inline stylesheet</title></head>
<body>
<font style="color:blue;font-size:18px;text-decoration:underline;font-
family:arial;">
HELLO WORLD!</font>
<p style="color:green;font-size:22px;font-family:courier new;text-
weight:bold;text-indent:20px;margin:15px;align:left">
you said the other day ,you thought we were deal happier,king children
for they were fightning and frieghten inspite of their money.</p>
</body></html>
Practical 1 F
Internal style sheet
<!DOCTYPE HTML>
<html>
<head><title>internal style sheet</title>
<style type="text/css">
body{background-color:lemon;color:green;}
h1{text-align:center;font-size:3-px;font-family:arial;text-indent:10px;}
h3{color:#800000;left-margin:25px;background-color:yellow;}
ul.one{font-family:algerian;font-size:20px;color:red;}
ul.two{font-family:times new roman;font-size:22px;color:blue;}
</style>
</head>
<body>
<h1>INTERNAL STYLE SHEET DEMONSTRATION</h1>
<h3>LIST OF PROGRAMMING LANGUAGES</h3>
<ul type="disc" class="one">
<li>HTML</li>
<li>JAVASCRIPT</li>
<li>php</li></ul>
<ul type="square" class="two">
<li>c</li>
<li>c++</li>
<li>python</li>
</ul></body></html>
Practical 2 A
Different table
<!DOCTYPE HTML>
<html>
<head>
<title>TABLE</title></head>
<body>
<table border="1" cellpadding="1" height="2" widht="2"
align="center">
<tr>
<th rowspan="3" align="center" valign="middle">DAY</th>
</tr>
<tr>
<th colspan="2" >SCHEDULE</th>
<th rowspan="2">TOPIC</th>
</tr>
<tr>
<th>BEGIN</th>
<th>END</th>
</tr>
<tr>
<th rowspan="2">MONDAY</th>
<td rowspan="2">8:00am</th>
<td rowspan="2">5:00pm</th>
</tr>
<tr>
<td>VALIDITY OTD & RELAX MG</td>
</tr>
<tr>
<th rowspan="3" align="center">TUESDAY</th>
<td >8:00am</th>
<td >10:00am</th>
<td rowspan="2" >X PATH</td></tr>
<tr><td>10:00am</td>
<td>2:00pm</td>
</tr>
<tr>
<td>2:00pm</td>
<td>5:00pm</td>
<td>X SL TRANSFORMATION</td>
</tr>
<tr>
<th>WEDNESDAY</th>
<td >8:00am</th>
<td >2:00pm</th>
<td>X SL FORMATTING</td>
</tr>
</table>
</body>
</html>
Practical 2 B
Image mapping
Source Code:
<!doctype html><html>
<head>
<title>Image Mapping</title>
</head>
<body>
<h3><u><b><center>Image Mapping</center></b></u></h3>
<center><img src="1.jpg" width="800" height="400" alt="sky"
usemap="#abc"></center>
<map name="abc">
<area shape="circle" coords="634,131,53" alt="Mumbai"
href="mumbai.html">
<area shape="rect" coords="320,164,69,44" alt="Delhi"
href="delhi.html">
<area shape="poly" coords="500,406,377,275,377,407" alt="Chennai"
href="chennai.html">
</map>
</body></html>
Practical 2 C
Form contents
<!DOCTYPE HTML>
<html>
<head>
<title>CUSTOMER INFORMATION</title></head>
<body bgcolor="red">
<font color="black">
<table border="0" align="center" cellpadding="1">
<form>
<tr>
<td colspan="2">
<h1 align="center" ><u>CUSTOMER INFORMATION</u></h1>
</td></tr>
<tr>
<td>CUSTOMER ID:</td>
<td><input type="number" size="20" maxlength="15"></td>
</tr>
<br>
<tr>
<td>CUSTOMER NAME:</td>
<td><input type="text" size="20" maxlength="20"></td>
</tr>
<br>
<tr>
<td>ADDRESS:</td>
<td><textarea name="t1" rows="4" cols="30"></textarea></td>
</tr>
<br>
<tr>
<td>GENDER:</td>
<td><input type="radio" name="gender" value="female"
checked="checked">FEMALE
<input type="radio" name="gender" value="male" >MALE</td>
</tr>
<br>
<tr>
<td>CONTACT NUMBER:</td>
<td><input type="number" size="20" maxlength="12"></td>
</tr>
<br>
<tr>
<td>PRODUCT BROUGHT:</td>
<td><input type="checkbox" name="i1" value="shirts">SHIRTS
<input type="checkbox" name="i2" value="T-shirts">T-SHIRTS
<input type="checkbox" name="i3" value="jeans">JEANS
</td>
</tr>
<br>
<tr>
<td>SIZE:</td>
<td><select name="size">
<option value="s">S</option>
<option value="m">M</option>
<option value="l">L</option>
<option value="xl">XL</option>
</select>
</td>
</tr>
<br>
<tr>
<td>COLOUR:</td>
<td><input type="color" name="fav color"></td>
</tr>
<br>
<tr>
<td>DATE:</td>
<td><input type="DATE" ></td>
</tr>
<br>
<tr>
<td><input type="SUBMIT" value="SUBMIT">
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
<input type="reset" value="CLEAR">
</td>
</tr>
<br>
</form>
</table></font></body></html>
Practical 2 D
Multimedia feature
<!doctype html>
<html>
<head>
<title></title>
<body><center>
<h1>Welcome to Multimedia Features</h1>
<br>
<br>
<h3>Video with Video and Source tags</h3>
<video controls height="400" width="400" autoplay>
<source src="Shaun the Sheep The Movie – Official Trailer.mp4"
type="video/mp4">
</video><br>
<h3>Video with Embed tags</h3>
<embed src="Shaun the Sheep The Movie – Official Trailer.mp4"
height="400" width="400" autostart="true"><br><br>
<h3>Audio with Audio and Source tags</h3>
<audio controls height="400" width="400" autoplay>
<source src="Shaun the Sheep The Movie – Official Trailer.mp3"
type="audio/mp3">
</audio><br>
<h3>Audio with Embed tags</h3>
<embed src="Shaun the Sheep The Movie – Official Trailer.mp3"
height="400" width="400" autostart="true"><br>
</center>
</body></html>
Practical 2 E

Semantic tags

<!doctype html>

<html><head>

<title>Semantic Tags</title>

</head><body>

<section> <h1>WWF</h1>

<p>The Worldwide fund for nature(WWF) is an international


organization working on issues regarding the conservation, research and
restoration of the environment, formerly named 'the world wild life
fund'. WWF was founded in 1961</p>

<section>

<h1>WWF Panda Symbol</h1>

<p> The Panda has become the symbol of WWF. The well known panda
originated from the panda named Chee Chee, that was transferred from
the Beijing Zoo to the London Zoo in the same year of the establishment
of WWF.</p>

</section>

</section><hr>

<article>

<nav><a href="a.html">HTML</a>

<a href="b.html">CSS</a>

<a href="c.html>Javascript</a>
<a href="d.html">Php</a>

</nav>

<header>

<h1>What does WWF do?</h1>

<p>WWF's Mission</p>

</header>

<p>WWF's mission is to stop the degradation of our planet's natural


environment, and build a future in which humans live in harmony with
nature.</p>

<p>We last updated on<time>9|2|2018 08:00 HRS</time></p>

<footer>

<p>posted by:Hege Refsenes</p>

<p>contact information:<a href="mailto:someone@example.com">

</footer>

</article>

<hr>

<p>My family and I visited the <mark>Epcot center</mark>the


summer</p>

<hr>

<figure>

<img src="krrish08.jpg" alt="krrish" width="400" height="400">

<figcaption> fig1-The Krrish</figcaption>


<aside>

<h4>Epcot Center</h4>

<p>The Epcot center is here a park in Disney Land, Florida</p>

</article>

</figure><hr>

<main>

<h1>Web browsers</h1>

<p>Google Chromes, Firefox, Internet Explorer are the most used


browers today.</p>

</article>

<h1>Google Chrome</h1>

<p>Googl chrome is a free open sorce browser developed by google,


released in 2008.</p></article>

<h1>Internet Explorer</h1>

<p>Internet Explorer is a free open sorce browser from microsoft,


released in 1995.</p>

</article>

<article>

<h1>Mozilla Firefox</h1>

<p>Firefox is a free open source browser from mozilla, released in


2004.</p>

</article>

</main><hr>
<detail>

<summary>Copyright 1999-2018</summary>

<p>-by reference data

All rights reserved</p>

</details></body></html>
Practical 3 A

Factorial / Fibonacci

<!doctype html><html>

<head><title>factorial/Fibonacci series</title></head>

<body>

<script type="text/javascript">

document.write("-------Factorial-------"+"&nbsp;"+"&nbsp;"+"&nbsp;"

+"&nbsp;"+"&nbsp;"+"&nbsp;");document.write("-------Fibonacci series--
-----"+"<br>");

var i;var fact=1;

for(i=1;i<=5;i++)

fact=fact*i;}

document.write("Factorial of 5 is "+fact+"&nbsp;"+"&nbsp;"

+"&nbsp;"+"&nbsp;"+"&nbsp;"+"&nbsp;");

var a= 0;var i;var b=1;

document.write(a+"\t");

document.write(b+"\t");

for(i=1;i<=8;i++){

c=a+b;

document.write(c+"\t");

a=b;
b=c;}</script></body></html>
Practical 3 B

Validation of controls

<!doctype html><html>

<head><title>Registration form</title>

<script type="text/javascript">

function validate()

var fname=document.f1.txtfname.value;

var email=document.f1.txtemail.value;

var mob=document.f1.txtmob.value;

var country=document.f1.optcountry.value;

if(fname==" ")

alert("Name must be filled out");

document.f1.txtfname.focus();

result;

else

for(i=0;i<fname.length;i++)

{
al=fname.substring(i,i+1);

if((al>="A"&&al<="Z''')||(al>="a"&&al<="z"));

else

alert("Enter valid name");

document.f1.txtfname.value=" ";

document.f1.txtfname.focus();

return;

if(email==" ")

alert("Please provide your email");

document.f1.txtemail.value=" ";

document.f1.txtemail.focus();

return false;}

else{

pos1=email.indexOf("@");

pos2=email.lastindexOf(".");

if(!(pos1>0&&pos2>pos1+1)){
alert("Invalid email");

document.f1.txtemail.value=" ";

document.f1.txtemail.focus();

return;}

if(mob==""||isNaN(mob)||mob.length!=10){

alert("Please provide 10 digit mobile number");

document.f1.txtmob.value=" ";

document.f1.txtmob.focus();

return;}

if(country==-1){

alert("Please provide your country");

return;}

else{

alert(f1.txtfname.value+" have been registered");

return true;}}

</script>

</head>

<body><form name="f1" onsubmit="3b.html"><fieldset>

First name:<input type="text" name="txtfname"><br>

Email:<input type="text" name="txtemail"><br>

Mobile:<input type="tel" name="txtmob"><br>


Country:<select name="optcountry">

<option value=-1 selected>Select Country</option>

<option value=1>India</option>

<option value=2>USA</option>

<option value=3>UK</option>

</select>

<input type="button" value="submit" onclick="validate();">

</fieldset>

</form>

</body>

</html>
Practical 3 C
Prime numbers

<!doctype html><html>

<head>

<title>Prime numbers</title>

</head>

<script>

function printPrime(){

var i = 0;

var j = 0;

for (i = 1; i <=100; i++) {

c = 0;

for (j = 1; j <= i; j++) {

// % modules will give the reminder value, so if the reminder is 0 then it


is divisible

if (i % j == 0) {

//increment the value of c

c++;

//if the value of c is 2 then it is a prime number


//because a prime number should be exactly divisible by 2 times only
(itself and 1)

if (c == 2) {

document.getElementById("result").insertAdjacentHTML('beforeend',i +
'<br>');

Roll No:21

</script>

</head>

<body>

<h2>JavaScript to print Prime numbers!</h2>

<input type="submit" value="Print Prime Numbers"


onclick="printPrime()" name="print" />

<div id="result"></div>

</body>

</html>
Practical 3 D
Sum of Digit of no.

<html>

<head><title>Sum of Digit of no.</title></head>

<script type="text/javascript">

function sum()

var n1=parseInt(document.form1.n1.value);

var sum=0;

var a=0;

while(n1>0)

a=parseInt(n1%10);

sum=parseInt(sum+a);

n1=parseInt(n1/10);

alert("sum of digit="+sum);

document.write("sum of digit="+sum);

</script>

</head>
<body>

<form name ="form1" method="get">

enter the number:

<input type="text" name="n1">

<br/>

<input type="button" value="sum of digit" onclick="sum();">

</body>

</html>
Practical 3 E

Simple calculator

<html>

<head>

<body>

<script type="text/javascript">

function add()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

var ad=n1+n2;

alert("value"+ad);

function sub()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

var sb=n1-n2;

alert("value"+sb);
}

function mul()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

var ml=n1*n2;

alert("value"+ml);

function div()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

var dv=n1/n2;

alert("value"+dv);

function mod()

var n1=parseInt(f1.t1.value);

var n2=parseInt(f1.t2.value);

var md=n1%n2;
alert("value"+md);

</script>

<form name="f1" method="get">

<input type="text" name="t1"/ >

<input type="text" name="t2"/>

<input type="submit" value="add" OnClick="add();"/>

<input type="submit" value="sub" OnClick="sub();"/>

<input type="submit" value="mul" OnClick="mul();"/>

<input type="submit" value="div" OnClick="div();"/>

<input type="submit" value="mod" OnClick="mod();"/>

</form>

</body>

</html>
Practical 4 A (IF)

If statements

<html>

<head>

<title><h1>conditional statement</h1></title>

</head>

<body>

<script type="text/javascript">

var i=67;

if(i>40)

document.write("congrats!!passed");

</script>

</body>

</html>
Practical 4 A (IF ELSE)
If Else statements

<html>

<head>

<title>conditional statement</title>

</head>

<body>

<script type="text/javascript">

var marks=70;

if(marks>40)

document.write("congrats!! passed");

else

document.write("fail");

</script>

</body>

</html>
Practical 4 A (switch)

Switch statements

<html>

<head>

<title>good</title>

</head>

<body>

<script type="text/javascript">

var no=parseInt(prompt("enter the no:"))

switch(no)

case 1:

document.write("good morning");

break;

case 2:

document.write("good afternoon");

break;

case 3:

document.write("good evening");

break;

default:
document.write("good night");

break;

</script>

</body>

</html>
Practical 4 B (For loop)

<!doctype html><html>

<head><title></title>

<script type="text/javascript">

function f()

var n=prompt("Enter a number");

var flag=0;

for(var i=2;i<n;i++){

if(n%i==0){

flag=1;

break;}}

if(flag==0){

alert("The Number "+n+" is a Prime number");}

else{

alert("The Number "+n+" is not a Prime number");}}

</script></head>

<body><form>

<input type="button" onclick="f();"


value="Prime"></form></body></html>
Practical 4 B (While loop)

Source Code:

<!doctype html><html>

<head><title></title>

<script type="text/javascript">

function f(){

var d;var rev=0;var n=prompt("Enter a number");var n1=n;

while(n1>0){

d=n1%10;

rev=rev*10+d;

n1=n1/10;}

if(n==rev){

alert("The Number "+n+" is a Palindrome");}

else{alert("The Number "+n+" is not a Palindrome");}}

</script></head><body><form><input type="button" onclick="f();"


value="Palindrome"></form></body></html>
Practical 4 B (Do While)

Source Code:

<!doctype html><html>

<head><title></title>

</head>

<body>

<script type="text/javascript">

document.write("Numbers from 1 to 10"+"<br>");

var i=1;

do{

document.write(i+"<br>");

i++;}

while(i<=10)

</script>

</body>

</html>
Practical 4 C

Java script

Source Code:

<!doctype html>

<html>

<head>

<title></title>

<script type="text/javascript">

var answer1 = "It's alright";

var answer2 = "He is called 'Johnny'";

var answer3 = 'He is called "Johnny"';

var book=new Object();

book.subject="perl";

var fruits=["apple","banana","mango","orange"];

var date=new Date();

var pi_val=Math.PI;

var sin_val=Math.sin(30);

var str ="Visit W3Schools!";


var n = str.search(/w3Schools/i);

var num=new Number(8);

var bool=new Boolean(10>9);

</script>

</head>

<body>

<script type="text/javascript">

document.write("String object:"+"<br>");

document.write("You can use quotes inside a string, as long as they


don't match the quotes surrounding the string.");

document.write(answer1+"<br>");

document.write(answer2+"<br>");

document.write(answer3+"<br>"+"<br>");

document.write("Object Consructor:"+"<br>");

document.write("book.name:"+book.subject+"<br>"+"<br>");

document.write("Array object:"+"<br>");

document.write("fruits name:"+fruits+"<br>"+"<br>");

Roll No:21

document.write("Date object:"+"<br>");

document.write("Date:"+date+"<br>"+"<br>");
document.write("Math object:"+"<br>");

document.write("PI:"+pi_val+"<br>");

document.write("Sin:"+sin_val+"<br>"+"<br>");

document.write("RegExp object:"+"<br>");

document.write("Search a string for w3Schools and the position of the


match: "+n+"<br>"+"<br>");

document.write("Number object:"+"<br>");

document.write("Number:"+num+"<br>"+"<br>");

document.write("Boolean object:"+"<br>");

document.write("Boolean:"+bool+"<br>");

</script> </body></html>
Practical 5 A

factorial

<html>

<head>

<title>factorial</title></head>

<body>

<h1>factorial</h1>

<form action="fact.php" method="Post" >

Enter the Number: <input type="text" name="fac">

<input type="submit" value="submit"> </form>

<?php

$n=$_POST['fac'];

$f=1;

for($i=1;$i<=$n;$i++)

{ $f=$f*$i; }

echo"factorial of the number is:".$f;

?>

</body>

</html>
Practical 5 B
Checking Prime number

<html>

<head><title>Prime number</title>

</head>

<body>

<form action="pr.php" method="GET" >

Enter the Number: <input type="text" name="pr">

<input type="submit" value="submit"> </form>

<?php

$p=$_GET["pr"];

$flag=0;

for($i=2;$i<$p;$i++)

{ if($p%$i==0)

{ $flag=1;

break; }

if($flag==0)

{echo"Number is prime";}

else

{echo"Number entered is not prime".$p;}


?> </body> </html>
Practical 6 A
Greatest of two number

<html>

<head><title>greatest number</title>

</head>

<body>

<form action="grp.php" method="GET" >

Enter the first number: <input type="text" name="gr">

Enter the second number: <input type="text" name="cr">

<input type="submit" value="submit"> </form>

<?php

$g=$_GET["gr"];

$c=$_GET["cr"];

if($g>$c)

{ echo"First number is greater"; }

else

{ echo"Second number is greater than 1st number"; }

?>

</body>

</html>
Practical 6 B

Binary pyramid

<html>

<head>pyramid<head>

<body>

<?php

$a=8;

for($i=1;$i<=5;$i++)

{for($j=1;$j<$i;$j++)

{if($a%2==0)

{echo "1";}

else

{echo "0";}

echo " ";

$a++;

} echo "<br>";

?>

</body>

</html>
Practical 7 A
string functions

<html>

<head><title>string functions</title>

</head>

<body>

<?php

echo strlen("hello world")."<br>";

echo str_word_count("hello world")."<br>";

echo strrev("hello world")."<br>";

echo strpos("hello world","world")."<br>";

echo str_replace("world","everyone","hello world")."<br>";

echo strtolower("HELLLO WORLD")."<br>";

echo strtoupper("hello world")."<br>";

echo substr("hello world",0,5)."<br>";

echo substr("hello world",6,5)."<br>";

?>

</body></html>
Practical 7 B

one dimensional array

<html>

<head><title>one dimensional array</title></head>

<?php

$price=array("mouse"=>320,"monitor"=>2000,"keyboard"=>1400);

echo"the price of mouse is Rs:".$price['mouse'];

?>

</body>

</html>
Practical 8 A (php)

<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die("Could Not Connect".mysql_error());
}
if(mysql_query("Create Database College",$con))
{
echo "Database Created";
}
else
{
echo "Error Creating Database".mysql_error();
}
mysql_select_db("College",$con);
$sql="CREATE TABLE Department(E_name varchar(50),D_no
int,No_of_faculties int )";
mysql_query("$sql",$con);
mysql_close($con);
?>

<?php $con=mysql_connect("localhost","root","");

if(!$con)
{
die("Could Not Connect".mysql_error());
}
mysql_select_db("College",$con);
mysql_query("Insert into Department values(‘jayesh','10','22')");
mysql_query("Insert into Department values('zaid','20','24')");
mysql_close($con);
?>

Potrebbero piacerti anche