Slip
18
Write
a java script program to accept the value of n and display all odd numbers up
to n.
<html>
<head>
<script>
function
printOddNums()
{
//get the
start and end range from user
var start =
document.getElementById("start").value;
var end =
document.getElementById("end").value;
var oddNums
= "<br>Odd Numbers:<br>";
for(i=start;
i<=end; i++){
// let's
divide the value by 2
// if the
reminder is not a zero then it's an odd number
if(i % 2 !=
0){
oddNums += i
+ "<br>";
}
}
//print the
values
document.getElementById("result").innerHTML
= oddNums;
}
</script>
</head>
<body>
Start:
<input type="number" min="0" id="start"
value="1" />
End:
<input type="number" id="end" min="1"
value="20" />
<input
type="button" onclick="printOddNums()" value="Print
Odd Numbers" />
<div
id="result"></div>
</body>
</html>
Write
the HTML code which generates the following output. (Use external CSS to format
the given table)
<html>
<body>
<table
border=1>
<tr>
<th
rowspan="2">Book No</th>
<th
rowspan="2"">BookName</th>
<th
colspan="2">Price</th>
</tr>
<tr>
<th>Rs.</th>
<th>Paise</th>
</tr>
<tr>
<td>101</td>
<td>DBMS</td>
<td>200</td>
<td>50</td>
</tr>
</table>
</body>
</html>