Friday, April 17, 2009

Write a program to display the multiples of two

Write a program to display the multiples of two. Include for loop in the scriptlet block and display the numbers.

Solution:
The file used in this exercise is Series.jsp. The file is saved in basic directory.
<html>
<body>
<h1>Displaying </h1>
<%
int res;
int j=2;
for(int i=1;i<11;i++)
{
res=j*i;
out.println(j + " * " + i + " = " + res);
out.println("<br>");
}
%>
</body>
</html>

The output of the program is as shown in Figure 6.1.

Figure 6.1: Output of Series.jsp

0 nhận xét: