Output
Output
Q1(2) Changed size of the image to 250 width and 400 height.
<html>
<head>
<title>Image Size</title>
</head>
<body><img src="image1.jpeg" width=”250” height=”400”></image></body>
</html>
OUTPUT:-
Q1(3) Transform the text “click here into a link that goes to
www.google.com”.
<html>
<head></head>
<body>
<h1><center><a
href="www.google.com">ClickToRedirect</a></center></h1>
</body>
</html>
OUTPUT:-
Q1(4) The image number 2 does not exists. Specify the alternate text
“istar.edu.in” for the image.
<html>
<head><title>Image Size</title></head>
<body><image src="img" width=250 height=400 alt="istar.edu.in"></image>
</body>
</html>
OUTPUT:-
</pre>
<p>My favorite color is <del>blue</del><ins>red</ins>!</p>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
<p>This text contains <sup>superscript</sup> text.</p></center>
</body>
</html>
OUTPUT:-
Q4 Show the use of events to change background color with HTML and
JavaScript.
If mouse button is pressed, background color should be red.
If mouse button is released up, background color should be
yellow.
<html>
<head>
<script type="text/javascript">
function f1()
{
document.body.style.background="red";
}
function blur()
{
document.body.style.background="yellow";
}
</script>
</head>
<body>
<form><center><input type="button" value="Click Me" onclick="f1()"
onblur="blur()" ></center>
</form>
</body>
</html>
OUTPUT:-
<body>
<form>
<input type="button" value="click" onclick="getvalue()" />
</form>
</body>
<html>
OUTPUT:-
"dhaval"=>array(
"php"=>85,
".net"=>65,
"c++"=>61));
for($i=0;$i<=4;$i++)
{
echo $name."<br>";
}
?>
OUTPUT:-
<form method="POST">
Enter number 1:-<input type="number" name="n1"><br>
Enter number 2:-<input type="number" name="n2"></br><input
type="submit" name="submit" value="add">
</form>
</body>
</html>
<?php
function addfunction($num1,$num2)
{
$sum=$num1+$num2;
echo"Sum of two numbers is:-",$sum;
}
if(isset($_POST["submit"]))
{
$a=$_POST['n1'];
$b=$_POST['n2'];
addfunction($a,$b);
}
?>
OUTPUT:-
}
else
{
echo "Enter valid number";
}
}
?>
<form method="POST">
<table border=0 align="center">
<tr align="center">
<td><h1>ARITHMATIC OPERATOR</h1></td>
</tr>
<tr>
<td>number1:<input type="text" name="number1">
number2:<input type="text" name="number2">
<hr>
1. Addition</br>
2. Subtraction</br>
3. Multiplication</br>
4. Division</br>
5. Modulus</br>
</hr>
Enter your choice</br><input type="n1" type="text" style="display: inline" />
<input name="submit" type="submit" value="Calculate"/>
</td>
</tr>
<tr>
<td align="center">Answer:<input type="text" name="result" value="<?php
echo @$total ?>" disable></td>
</tr>
</table>
</form>
</body>
</html>
OUTPUT:-
Q14 Display your name n times. Take the input through text box.
<html>
<body>
<form method ="POST">
<table>
<tr>
enter your name:</br>
<input type = "text" name = "name"></br>
</tr>
<tr>
print:<input type = "text" name = "t1"></br>
</tr>
<input type = "submit" name = "submit" value = "submit">
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$t2 = $_POST['t1'];
}
for($i = 1;$i <=$t2; $i++)
{
echo $name;
echo "<br>";
}
?>
</body>
</html>
OUTPUT:-
Q15 Write HTML and PHP script to check whether given number is odd or
even. Take the input through text box.
<html>
<head>
</head>
<body>
<form method="POST">
Enter number:-<input type="number" name="n1"><br>
<input type="submit" name="submit" value="add">
</form>
</body>
</html>
<?php
if(isset($_POST["submit"]))
{
$a=$_POST['n1'];
if($a%2==0)
{
echo"Number $a is even";
}
else
{
echo"Number $a is odd";
}
}
?>
OUTPUT:-
Q17 Write HTML and PHP script to check whether given number is
armstrong or not. Take the input through text box and display output
also in text box.
<html>
<body>
<form action="" method="post">
<input type="text" name="number">
<input type="submit">
</form>
</body>
</html>
<?php
if($_POST )
$number = $_POST['number'];
$t1 = $number;
$sum = 0;
while($t1 != 0)
{
$rem = $t1 % 10;
$sum = $sum + ( $rem * $rem * $rem);
$t1 = $t1 / 10;
}
if($number == $sum)
{
echo "$number is armstrong number";
}
else
{
echo "$number is not armstrong number";
}
?>
OUTPUT:-
Q18 Write HTML and PHP code to find factorial n numbers using recursion
function. (i.e. HTML allows to enter input through textbox and when
submit button is clicked then it displays numbers)
<html>
<head>
</head>
<body>
<form method="POST">
Enter number:-
<input type="number" name="number"><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$number = $_POST['number'];
$fact = factorial($number);
echo"factorial of number:".$fact;
}
function factorial($number)
{
if($number<=1)
{
return 1;
}
else
{
return ($number * factorial($number-1));
}
}
?>
OUTPUT:-
Q23 Find the greater value between three variables using Ternary
Operator.
<html>
<body>
<form method="POST">
enter no1:<input type="text" name="n1"></br>
enter no2:<input type="text" name="n2"></br>
enter no3:<input type="text" name="n3"></br>
<input type="submit" name="submit" value="find!":>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$a=$_POST['n1'];
$b=$_POST['n2'];
$c=$_POST['n3'];
$greater = ($a>$b?($a>$c?$a:$c):($b>$c?$b:$c));
echo $greater." is greater value";
}
?>
OUTPUT:-
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($con);
}
mysqli_close($con);
?>
Output:
<pre>
<?php
$con = mysqli_connect("localhost", "root", "", "mydb");
$run=mysqli_query($con,$sql);
$data=mysqli_fetch_array($run);
while($data=mysqli_fetch_array($run)){
print_r($data);
}
?>
OUTPUT:-