Saturday, 24 January 2015

Javascript program to print the following pattern (for n input lines).

<!--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>

1 comment:

Read contacts in iOS using Swift with error handling

Just copy and paste the below code Pre-step before pasting the below code Add below line in AppDelegate.swift file below import statement ...