<!--Javascript program to print the following pattern (for n input lines).-->
<!--when n=4-->
10 09 08 07
06 05 04
03 02
01
<html>
<head>
<title>Javascript</title>
<script type="text/javascript">
var a;
var b=10;
var n=prompt("Enter a number for no. of rows in a pattern.");
for(var i=n;i>=1;i--)
{
for(var j=1;j<=i;j++)
{
if(j==1 && i==n)
document.write(b+" ");
else
document.write("0"+b+" ");
b--;
}
document.write("<br />");
}
</script>
</head>
<body>
</body>
</html>
<!--when n=4-->
10 09 08 07
06 05 04
03 02
01
<html>
<head>
<title>Javascript</title>
<script type="text/javascript">
var a;
var b=10;
var n=prompt("Enter a number for no. of rows in a pattern.");
for(var i=n;i>=1;i--)
{
for(var j=1;j<=i;j++)
{
if(j==1 && i==n)
document.write(b+" ");
else
document.write("0"+b+" ");
b--;
}
document.write("<br />");
}
</script>
</head>
<body>
</body>
</html>
This comment has been removed by the author.
ReplyDelete