Tybsc (Comp - Science) PHP Practical Exam Question Bank 20-21 Reduced Syllabus Sem-I and Sem-Ii

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

TYBSc (Comp.

Science )
PHP Practical Exam Question Bank 20-21
Reduced Syllabus Sem-I and Sem-II

//String
Set-A
Q: 1) Write a PHP script for the following: Design a form to accept a string. Write a
function to count the total number of vowels (a,e,i,o,u) from the string. Show the
occurrences of each vowel from the string. Check whether the given string is a
palindrome or not, without using built-in function. (Use radio buttons and the concept of
function. Use ‘include’ construct or require stmt.)

Q: 2) Write a PHP script for the following: Design a form to accept two strings from the
user. Find the first occurrence and the last occurrence of the small string in the large
string. Also count the total number of occurrences of small string in the large string.
Provide a text box to accept a string, which will replace the small string in the large
string. (Use built-in functions)

Set-B:
Q: 3) Write a PHP script for the following: Design a form to accept two numbers from
the user. Give options to choose the arithmetic operation (use radio buttons). Display
the result on the next form. (Use the concept of function and default parameters. Use
‘include’ construct or require stmt)
Q: 4) Write a PHP script for the following: Design a form to accept two strings from the
user. Find whether the small string appears at the start of the large string. Provide a text
box to accept the string that will replace all occurrences of small string present in the
large string. Also split the large string into separate words. (Use regular expressions)

Set-C:
Q: 5) Write a PHP script for the following: Design a form to accept the details of 5
different items, such as item code, item name, units sold, rate. Display the bill in the
tabular format. Use only 4 text boxes. (Hint : Use of explode function.)

Q: 6) Write a PHP script for the following: Design a form to accept two strings. Compare
the two strings using both methods (= = operator & strcmp function). Append second
string to the first string. Accept the position from the user; from where the characters
from the first string are reversed. (Use radio buttons)

Q:7) Using regular expressions check for the validity of entered email-id. The @ symbol
should not appear more than once. The dot (.) can appear at the most once before @
and at the most twice or at least once after @ symbol. The substring before @ should
not begin with a digit or underscore or dot or @ or any other special character. (Use
explode and ereg function.)
//Array
Set-A
Q: 8) Write a menu driven program to perform the following operations on an
associative array:
a) Display the elements of an array along with the keys.
b) Display the size of an array
c) Delete an element from an array from the given key/index.
d) Reverse the order of each element’s key-value pair [Hint: use array_flip()]
e) Traverse the elements in an array in random order [[Hint: use shuffle()].

Q:9) Accept a string from the user and check whether it is a palindrome or not
(Implement stack operations using array built-in functions).

Set-B
Q: 10) Declare a Multidimensional Array. Display specific element from a
Multidimensional array. Also delete given element from the Multidimensional
array.(After each operation display array content [Hint : use print_r() ] )

Q: 11) Define an array. Find the elements from the array that matches the given
value using appropriate search function.

Set-C
Q: 12) Write a menu driven program to perform the following stack and queue related
operations:[Hint: use Array_push(), Array_pop(), Array_shift(), Array_unshift() ]
a) Insert an element in stack
b) Delete an element from stack
c) Display the contents of stack
d) Insert an element in queue
e) Delete an element from queue
f) Display the contents of queue

Q: 13) Write a menu driven program to perform the following operations on associative
arrays:
a) Sort the array by values (changing the keys) in ascending, descending
order.
b) Also sort the array by values without changing the keys.
c) Filter the odd elements from an array.
d) Sort the different arrays at a glance using single function.
e) Merge the given arrays.
f) Find the intersection of two arrays.
g) Find the union of two arrays.
h) Find set difference of two arrays.

//File
Set-A
Q: 14) Write a program to read two file names from user and append contents of first
file into second file.

Q: 15) Write program to read directory name from user and display content of the
directory.

Set-B
Q: 16) Write a program to read a flat file “student.dat”, calculate the percentage and
display the data from file in tabular format.(Student.dat file contains rollno, name,
Syspro, TCS, CN, PHP, JAVA, BA )

Q: 17) Write a program to read directory name and extension. Display the files with
specified extension from that directory.

Set-C
Q: 18) Write a menu driven program to perform various file operations.
a) Display size of file
b) Display Last Access, changed, modified time of file
c) Display details about owner and user of File
d) Display type of file
e) Delete a file
f) Copy a file
g) Traverse a directory in hierarchy
h) Remove a directory

Q: 19) Write a program to read directory name from user and display content of the
directory recursively.

SEM-II
// Form Design
Set-A:
1) Design a webpage for the following layout
For Student profile – where student rno, name, contact, photo, class
in column 1 and area of interest, subjects , topics(has read more link)
in column 2.
2) Create a login form with a username and password. Once the user logs
in, the second form should be displayed to accept user details (name, city,
phoneno). If the user doesn’t enter information within a specified time
limit, expire his session and give a warning.

ANS:

a2.html
<html>
<head><title> Login Form</title></head>
<body>
<form method="POST" action="a2.php">
Username:<input type="text" name="user"><br>
Password:<input type="password" name="pass"><br>
<input type="submit" value="submit">
</form>
</body>
</html>
 
a2.php
 
<?php
session_start();
$_SESSION['tm']=time();
?>
<form method="GET" action="new.php">
Roll no:<input type="text" name="rno"><br>
Name:<input type="text" name="nm"><br>
City<input type="text" name="ct"><br>
<input type="submit" value="submit">
</form>
 
new.php
 
<?php
session_start();
$new=$_SESSION['tm']+20;
if($new<time())
echo "Time out";
else
{
echo"roll no=$_GET[rno]<br>";
echo"name=$_GET[nm]<br>";
echo"city=$_GET[ct]<br>";
}
session_destroy();
?>
Output:enter values and click ok..

=================================================================
=================================================================
=================================================================
=======================================

Set-B
3) Design a webpage of three columns with following data Information for
placement Like personal details – in one column, Educational details – in
second column, technical skills-in third column

ANS:
b1.html
 
<html><head>
<title>Personal Details</title>
</head>
<body>
<form method="GET" action="as1.php">
Please enter First name:
<input type="text" name="t1"><br>
Please enter Middle name:
<input type="text" name="t2"><br>
Please enter Last name:
<input type="text" name="t3"><br>
Please enter City name:
<input type="text" name="t4"><br>
Please enter State name:
<input type="text" name="t5"><br>
Please enter College name:
<input type="text" name="t6"><br>
Please enter Course name:
<input type="text" name="t7"><br>
Sex<br>
Male<input type="radio" name="r1" value="male"><br>
Female<input type="radio" name="r1" value="female">
<br>
<input type="submit" value="submit">
</form>
</body>
</html>
 
as1.php
 
<?php
session_start();
$_SESSION['t1']=$_GET['t1'];
$_SESSION['t2']=$_GET['t2'];
$_SESSION['t3']=$_GET['t3'];
$_SESSION['t4']=$_GET['t4'];
$_SESSION['t5']=$_GET['t5'];
$_SESSION['t6']=$_GET['t6'];
$_SESSION['t7']=$_GET['t7'];
$_SESSION['r1']=$_GET['r1'];
?>
<html>
<body>
<form method="GET" action="as2.php">
enter Your edu<input type="text" name="t8"><br>
enter your marks<input type="text" name="t9"><br>
<input type="submit" value="submit">
</form>
</body>
</html>
 
as2.php
 
<?php
session_start();
$_SESSION['t8']=$_GET['t8'];
$_SESSION['t9']=$_GET['t9'];
?>
<body>
<form method="GET" action="as3.php">
enter your techinical skill<input type="text" name="t10"<br>
<input type="submit" value="submit">
</form>
</body>
 
 
 
 
as3.php
<html>
<head>Candidate Details</head>
<body>
<table border=2 colspan=3>
<tr>
<td>
<h5>Personal Details<h5>
<?php
session_start();
echo"First Name:  ".$_SESSION['t1']."<br>";
echo"Middle Name:  ".$_SESSION['t2']."<br>";
echo"Last Name:  ".$_SESSION['t3']."<br>";
echo"City Name:  ".$_SESSION['t4']."<br>";
echo"State Name:  ".$_SESSION['t5']."<br>";
echo"College Name:  ".$_SESSION['t6']."<br>";
echo"Course Name:  ".$_SESSION['t7']."<br>";
echo"Gender Name:  ".$_SESSION['r1']."<br>";
?>
</td>
<td>
<h5>Education Details</h5>
<?php
echo"Degree :  ".$_SESSION['t8']."<br>";
echo"Marks:  ".$_SESSION['t9']."<br>";
?>
</td>
<td>
<h5>Technical Details</h5>
<?php
echo"Tecnical Skill:  ".$_GET['t10']."<br>";
session_destroy();
?>
</td>
</tr>
</table>
</body>
</html>

=================================================================
=================================================================
=================================================================
=====================================
4) Change the preferences of your web page like font style, font size, font
color, background color using cookie. Display selected settings on
next web page and actual implementation (with new settings) on third web
page.

ANS:
b2.html
 
<html>
<body>
<form action="a1.php" method="get">
<center>
<b>Select font style :</b><input type=text name=s1><br>
<b>Enter font size :</b><input type=text name=s><br>
<b>Enter font color :</b><input type=text name=c><br>
<b>Enter background color :</b><input type=text name=b><br>
<input type=submit value="Next">
</center>
</form>
</body>
</html>
 
a1.php
 
<?php
echo "style is ".$_GET['s1']."<br>color is ".$_GET['c']."<br>Background color is ".
$_GET['b']."<br>size is ".$_GET['s'];
 
setcookie("set1",$_GET['s1'],time()+3600);
setcookie("set2",$_GET['c'],time()+3600);
setcookie("set3",$_GET['b'],time()+3600);
setcookie("set4",$_GET['s'],time()+3600);
?>
 
<html>
<body>
<form action="aa2.php">
<input type=submit value=OK>
</form>
</body>
</html>
 
aa2.php
 
<?php
$style=$_COOKIE['set1'];
$color=$_COOKIE['set2'];
$b_color=$_COOKIE['set3'];
$size=$_COOKIE['set4'];
$msg="PHP Classes";
echo "<body bgcolor=$b_color>";
echo "<font color=$color size=$size ><$style>$msg</$style>";
echo "</font></body>";
?>
=================================================================
=================================================================
==========================

5) Create a form to accept student information (name, class, address).


Once the student information is accepted, accept marks in next form
(Phy, Bio , Chem, Maths, Marathi, English) .Display the mark sheet for the
student in the next form containing name, class, marks of the subject,
total and percentage.

ANS:

b3.html
 
<html>
<body>
<form method="get" action="b31.php">
enter name of student:<input type="text" name="name">
enter the class:<input type="text" name="class">
enter the address:<input type="text" name="address">
<input type="submit" value="submit">
</form>
</body>
</html>
 
b31.php
 
<?php
setcookie("name",$_GET['name']);
setcookie("class",$_GET['class']);
setcookie("address",$_GET['address']);
?>
<html>
<body>
<form action="b32.php" method="get">
Enter the marks for following subjects:<br>
English<input type="text" name="a"><br>
marathi<input type="text" name="b"><br>
Chemistry<input type="text" name="c"><br>
Physics<input type="text" name="d"><br>
Biology<input type="text" name="e"><br>
Maths<input type="text" name="g"><br>
<input type="submit" value="submit">
</form>
</body>
</html>
 
b32.php
 
<?php
echo"<br>Name is:".$_COOKIE['name'];
echo"<br>Class is:".$_COOKIE['class'];
echo"<br>Address is:".$_COOKIE['address'];
echo"<br><br>";
echo"<table border=3><tr><th>Subject</th><th>Marks</th></tr>";
echo"<tr><td>English</td><td>".$_GET['a']."</td><tr>";
echo"<tr><td>Marathi</td><td>".$_GET['b']."</td><tr>";
echo"<tr><td>Chemistry</td><td>".$_GET['c']."</td><tr>";
echo"<tr><td>Physics</td><td>".$_GET['d']."</td><tr>";
echo"<tr><td>Biology</td><td>".$_GET['e']."</td><tr>";
echo"<tr><td>Maths</td><td>".$_GET['g']."</td><tr></table>";
echo"<br>";
$total=$_GET['a']+$_GET['b']+$_GET['c']+$_GET['d']+$_GET['e']+$_GET['g'];
$per=$total/6;
echo"<br>Total of marks:=".$total;
echo "<br>percentage is:=".$per."%";
?>

=================================================================
=================================================================
=================================================================
=======================================

Set-C:
6) Design layout similar to your department webpage.

ANS:

=================================================================
=================================================================
=================================================================
=======================================

7) Write a program to create a shopping mall. User must be allowed to do


purchase from two pages. Each page should have a page total. The third
page should display a bill, which consists of a page total of whatever the
purchase has been done and print the total. (Use http session tracking).

ANS:

mall1.html
<html>
<head>
<title>Shopping MALL</title>
</head>
<body>
<form action="mall1.php" method=GET>
<h1><centre>SHOPPING MALL</h1>
<h3><centre>Page 1</h3>
<input type=checkbox name='shampoo' value='180'>SHAMPOO(DOVE): 180rs/-
<br>
<input type=checkbox name='deo' value='180'>DEODOURANT(FOGG):180/-<br>
<input type=checkbox name='hairwax' value='125'>HAIR WAX(GATSBY):125/-<br>
<input type=checkbox name='bodylotion' value='280'>BODY LOTION(NIVIA):280/-
<br>
<input type=checkbox name='hairoil' value='100'>HAIR OIL(PARACHUTE):100/-
<br>
<input type=submit value="SUBMIT">
</form>
</body>
</html>
 
mall1.php
<?php
session_start();
$_SESSION['shampoo']=$_GET['shampoo'];
$_SESSION['deo']=$_GET['deo'];
$_SESSION['hairwax']=$_GET['hairwax'];
$_SESSION['bodylotion']=$_GET['bodylotion'];
$_SESSION['hairoil']=$_GET['hairoil'];
 
$_SESSION['total']=$_GET['shampoo']+$_GET['deo']+$_GET['hairwax']+
$_GET['bodylotion']+$_GET['hairoil'];
 
?>
<html>
<head>
<title>Shopping MALL</title>
</head>
<body>
<form action="mall2.php" method=GET>
<h1><centre>SHOPPING MALL</h1>
<h3><centre>Page 2</h3>
<input type=checkbox name='tshirt' value='500'>T-shirts(Polo):500rs/-<br>
<input type=checkbox name='shirt' value='800'>Shirt(Van Heusen):800rs/-<br>
<input type=checkbox name='jeans' value='1250'>Jeans(Levis):1250rs/-<br>
<input type=checkbox name='shoes' value='2800'>Shoes(Puma):2800rs/-<br>
<input type=checkbox name='jacket' value='1500'>Jacket(Allen Solly):1500rs/-
<br>
<input type=submit value="SUBMIT">
</form>
</body>
</html>
 
mall2.php
<?php
session_start();
$_SESSION['tshirt']=$_GET['tshirt'];
$_SESSION['shirt']=$_GET['shirt'];
$_SESSION['jeans']=$_GET['jeans'];
$_SESSION['shoes']=$_GET['shoes'];
$_SESSION['jacket']=$_GET['jacket'];
 
$_SESSION['total1']=$_GET['tshirt']+$_GET['shirt']+$_GET['jeans']+$_GET['shoes']
+$_GET['jacket'];
 
echo"<centre><u>BILL</u>";
echo"<table border=2>";
$gtotal1=$_SESSION['total']+$_SESSION['total1'];
echo"</tr><td>the total of page 1 is:</td><td>$_SESSION[total]</td></tr>";
echo"<tr><td>the total of page 2 is:</td><td>$_SESSION[total1]</td></tr>";
echo"<tr><td>the grand total total is:</td><td>$gtotal1</td></tr>";
echo"</table>";
session_destroy();
?>

=================================================================
=================================================================
=================================================================
=======================================
8) Create a form to accept customer information(name, address, phno).
Once the customer information is accepted, accept product information
in the next form(Product name, qty, rate). Display the bill for the
customer in the next form. Bill should contain the customer information
and the information of the products entered.

ANS:
C3.html
<html>
<head>
<title>cookies</title></head>
<body>
<form action="ac1.php" method="GET">
<h4>Enter the Customer Name :<input type="text" name="cname">
<h4>Enter the Address of Customer :<input type="text" name="caddr" size="50">
<h4>Enter the Customer Ph. No. :<input type="text" name="cphone"></h4>
<br><center><input type="submit" value="Next"></center>
</form>
</body>
</html>
 
 
ac1.php
<?php
setCookie('name',$_GET['cname']);
setCookie('addr',$_GET['caddr']);
setCookie('phone',$_GET['cphone']);
?>
<html>
<head>
<body>
<form action="ac2.php" method="GET">
<h1>Select Products :-</h1><center>
<table><th>Product Name</th><th>Rate</th><th>Quantity</th></tr>
 
<tr><td><input type="checkbox" name="op[]" value="Keyboard">Keyboard</td>
<td><input type="text" name="0" size="5"></td>
<td><input type="text" name="10" size="3"></td></tr>
 
<tr><td><input type="checkbox" name="op[]" value="Monitor">Monitor</td>
<td><input type="text" name="1" size="5"></td>
<td><input type="text" name="11" size="3"></td></tr>
 
<tr><td><input type="checkbox" name="op[]" value="Mouse">Mouse</td>
<td><input type="text" name="2" size="5"></td>
<td><input type="text" name="12" size="3"></td></tr>
 
<tr><td><input type="checkbox" name="op[]" value="DVD">DVD</td>
<td><input type="text" name="3" size="5"></td>
<td><input type="text" name="13" size="3"></td></tr>
 
<tr><td><input type="checkbox" name="op[]" value="CD">CD</td>
<td><input type="text" name="4" size="5"></td>
<td><input type="text" name="14" size="3"></td></tr>
 
<tr><td><input type="checkbox" name="op[]" value="PenDrive">Pen Drive</td>
<td><input type="text" name="5" size="5"></td>
<td><input type="text" name="15" size="3"></td></tr>
 
</table>
<input type="submit" value="Bill"></center>
</form>
</body>
</head>
</html>
ac2.php
<?php
$pname=$_GET['op'];
echo"<center><b><h3><fontcolor=red>Customer
Information</font></center></h3>";
echo"CustomerName : $_COOKIE[name]<br>";
echo"Address : $_COOKIE[addr]<br>";
echo"PhoneNo. : $_COOKIE[phone]<br>";
echo"<center><caption><blink><b><font
color=red>BILL</blink></font></caption><table border=1 cellspacing=5
cellpadding=5><th>Product
Name</th><th>Quantity</th><th>Rate</th><th>Amount</th></tr>";
$total=0;
$j=10;
// K for product name I for rate and j for quantity
for($k=$i=0;$k<count($pname);$k++)
{
            $amt=$_GET[$i]*$_GET[$j];
            $total+=$amt;
           
           
echo"<tr><td>$pname[$k]</td><td>$_GET[$i]</td><td>$_GET[$j]</td><td>$amt
</td></tr>";$j++;$i++;
}
echo"<tr><td colspan=3 align=right><b>Total =
</td><td><b>$total</td></tr></table></center>";
?>

=================================================================
=================================================================
=================================================================
=======================================

//XML
Set-A
9) Write a script to create XML file named “Course.xml”

Store the details of 5 students who are in TYBSc.


ANS:

Xml

<?xml version="1.0" encoding="utf-8"?>


<course>
<computerscience>
<studentname>samir Thorat </studentname>
<classname>TYBCA. </classname>
<percentage>60 </percentage>
</computerscience>

<computerscience>
<studentname>sunil kamble </studentname>
<classname>TYBCA. </classname>
<percentage>55 </percentage>
</computerscience>
<computerscience>
<studentname>anil kamble </studentname>
<classname>TYBCA. </classname>
<percentage>60 </percentage>
</computerscience>

<computerscience>
<studentname>asha kamble </studentname>
<classname>TYBCA. </classname>
<percentage>65 </percentage>
</computerscience>

<computerscience>
<studentname>madhuri </studentname>
<classname>TYBCA. </classname>
<percentage>70 </percentage>
</computerscience>
</course>
=================================================================
=================================================================
=================================================================
=======================================

10) Link “Course.xml” file to the CSS style sheet and get well formatted
output as given below

ANS:
Css

studentname{
color:blue;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
font-size: 16px;

classname{
color: green;
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
font-size: 12px;

percentage{
color: red;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
font-style: oblique;
font-size: 14px;
Xml

<?xml version="1.0" encoding="utf-8"?>


<?xml-stylesheet type="text/css" href="ex9a1.css"?>
<course>
<computerscience>
<studentname>samir Thorat </studentname>
<classname>TYBCA. </classname>
<percentage>60 </percentage>
</computerscience>

<computerscience>
<studentname>sunil kamble </studentname>
<classname>TYBCA. </classname>
<percentage>55 </percentage>
</computerscience>
<computerscience>
<studentname>anil kamble </studentname>
<classname>TYBCA. </classname>
<percentage>60 </percentage>
</computerscience>

<computerscience>
<studentname>asha kamble </studentname>
<classname>TYBCA. </classname>
<percentage>65 </percentage>
</computerscience>

<computerscience>
<studentname>madhuri </studentname>
<classname>TYBCA. </classname>
<percentage>70 </percentage>
</computerscience>
</course>

=================================================================
=================================================================
=================================================================
=======================================
11) Write PHP script to generate an XML code in the following format

=================================================================
=================================================================
=================================================================
=======================================
12) Create a XML file which gives details of movies available in
“Mayanagari CD Store” from following categories

Save the file with name “movies.xml”.

=================================================================
=================================================================
=================================================================
=======================================
Set C
S

ANS:

Xml

<?xml version='1.0' encoding ='UTF-8' ?>


<bookstore>
<books category="technical">
<book_no>1</book_no>
<book_name>def</book_name>
<author_name>xxx</author_name>
<price>100</price>
<year>1990</year>
</books>
<books category="Cooking">
<book_no>2</book_no>
<book_name>ccc</book_name>
<author_name>aaa</author_name>
<price>200</price>
<year>1950</year>
</books>
<books category="YOGA">
<book_no>3</book_no>
<book_name>ddd</book_name>
<author_name>zzz</author_name>
<price>150</price>
<year>2016</year>
</books>
</bookstore>

Php

<?php
$xml=simplexml_load_file("ex9c1.xml") or die("eror:cannot create object");
var_dump($xml);
echo"<br><br>";
print_r($xml);
?>

=================================================================
=================================================================
=================================================================
=======================================
14) Write a script to create “cricket.xml” file with multiple elements as
given below

ANS:
Xml
<?xml version='1.0' encoding='UTF-8' ?>
<CricketTeam>
<Team country='India'>
<player>Sachin</player>
<runs>100</runs>
<wicket>4</wicket>
</Team>

<Team country='Austrelia'>
<player>smith</player>
<runs>10</runs>
<wicket>1</wicket>
</Team>
</CricketTeam>

=================================================================
=================================================================
==========================
=================================================================
=============

//javascript
Set-A

15) Write a javascript to display message ‘Good Morning’ using alert box.
ANS:

<html>
<body>
<script>
alert("Good Morning");
</script>
</body>
<html>
Output:
=================================================================
=================================================================
=================================================================
=======================================

16) Write a javascript to display message ‘Good Afternoon’ using function.


(Hint: use Event ‘Onload’).
ANS:
<html>
<body onload=func()>
<script>
function func()
{ document.write("<center><h2>Good Afternoon");
}
</script>
</body>
</html>
Output:
Good Afternoon

=================================================================
=================================================================
=================================================================
=======================================

SET B:

17) Write a javascript function to validate username and password for a


membership form.
ANS:
<html>

<body>

<h3> <center><script>

function func()

var u=document.myform.uname.value;

var p=document.myform.pwd.value;

if(u=="")

{alert(" Name can not be blank");

return false;

else if(p.length<6)

{ alert("Password length can not be less than 6 character");

return false;

</script>

<form name="myform" method="post" onsubmit="func()">

<br>

<b>Membership Form</b><br>

Enter User Name<input type="text" name="uname"><br><br>

Enter Password<input type="password" name="pwd"><br><br>


<input type="submit" value=submit>

</form>

</body>

</html>

Output

Membership Form
bhagyshri

Enter User Name

*********

Enter Password

submit

====================================================================================================
====================================================================================================
====================================================================================================

18) Using Javascript function, display the string in different formatting


styles(Bold, italic, underline, strikethrough, hypertext etc)
ANS:
<html>
<body onload="func()">
<script>
function func()
{
var txt="JAVA Script!!";
// document.write("Original Text :"+txt);
document.write("Original Text :"+txt);
document.write("<p>Big: " + txt.big() + "</p>");
document.write("<p>Small: " + txt.small() + "</p>");
document.write("<p>Bold: " + txt.bold() + "</p>");document.write("<p>Italic: " +
txt.italics() + "</p>");
document.write("<p>Fixed: " + txt.fixed() + "</p>");
document.write("<p>Strike: " + txt.strike() + "</p>");
document.write("<p>Fontcolor: " + txt.fontcolor("green") + "</p>");
document.write("<p>Fontsize: " + txt.fontsize(6) + "</p>");
document.write("<p>Subscript: " + txt.sub() + "</p>");
document.write("<p>Superscript: " + txt.sup() + "</p>");
document.write("<p>Link: " + txt.link("http://www.iccs.ac.in") + "</p>");
}
</script>
</body>
</html>

OUTPUT:

=================================================================
=================================================================
=================================================================
=======================================

SET C:

19) Write a Javascript to create a FIFO queue . Insert new element in it


(Hint: Use concept of Array )
ANS:
. . <!doctype html>
<html>
<head>
<script type="text/javascript">
var queue = new Array();
function queueAdd() { var inputValue = document.getElementById('txtInput').value;
if(inputValue) {
queue.push(inputValue); //unshift(inputValue);//
document.getElementById('txtInput').value = "";
}
}

function queueDel() {
var data = queue.shift();

if(!data) { data= "Queue is empty.";


}
document.getElementById('queueResult').innerHTML = data;
}
</script>
<title>JavaScript FIFO - Queue </title>
</head>
<body>
<center>
<h3>JavaScript Simple FiFo Queue</h3>
Input : <input type="text" id="txtInput" value="" name="txtInput">
<button onclick="queueAdd()">Add to queue</button>
<br /><br />
<button onclick="queueDel()">Delete from queue</button>
&nbsp;&nbsp;&nbsp;&nbsp;
<span id="queueResult">Result </span>
</center> </body>
</html>

OUTPUT:

JavaScript Simple FiFo Queue

Input : Add to queue

Delete from queue      Result

=================================================================
=================================================================
=================================================================
=======================================

20) Write a Javascript program to accept name of student, Change font


color to red, font size to 18 if student name is present otherwise on
clicking on empty text box display image which change its size (Use
onblur, onload, onmousehover, onmouseclick, onmouseup)

ANS:
<html>
<script>
function func()
{ var sr="smiley.gif";
var ww=document.getElementById("ee");
ww.src=sr;
}
function bigImg(x) {
x.style.height = "128px";
x.style.width = "128px";
}
function normalImg(x) { x.style.height = "64px";
x.style.width = "64px";
}
function myFunction(text1) {

// var str=document.getElementById("txt");
var result = text1.fontsize(7).fontcolor("green").bold();
document.getElementById("p1").innerHTML = result;
}
</script>
<body><center><br><br>
Enter Your Name <input type="text" onblur="myFunction(this.value)" id="txt"><br>
<p id="p1"></p>
<input type="button" value="click" onclick="func()">
<img src="" id="ee"onmouseover="bigImg(this)" onmouseout="normalImg(this)" >
</body>
</html>

OUTPUT:

You might also like