Thursday, 9 August 2018

PRINT STAR PATTERN IN JAVA SCRIPT

PRINT STAR PATTERN IN JAVA SCRIPT


----------------------------------------------------------------------------------------------------------
PRINT STAR PATTERN IN JAVA SCRIPT
----------------------------------------------------------------------------------------------------------
<html>
<!-- https://www.youtube.com/watch?v=ItOmYp9AKOA -->
<body>
<h2>JavaScript Loops</h2>
<script>
var rows = 5;
var cols = 5;
for (var i = 1; i <rows; i++) {
//FOR TRIANGLE SHAPE K LOOP 
for (var k = 1; k<=(rows-i); k++){
//FOR NONE BREAKING SPACE NBSP
document.write("&nbsp;");
}
for (var j = 1; j <=i; j++) {
document.write("*");
}
document.write("<br>");
}
</script>
</body>
</html>
<!-- // OUT PUT
*
**
***
****
*****
// -->
----------------------------------------------------------------------------------------------------------
DOCUMENT WRITE  TRIANGLE PATTERN
----------------------------------------------------------------------------------------------------------
<br/>
<br/>
<script>
document.write("<center>"+"*");
document.write("<center>"+"**");
document.write("<center>"+"***");
document.write("<center>"+"****");
document.write("<center>"+"*****");
</script>
----------------------------------------------------------------------------------------------------------
PRINT STAR PATTERN IN JAVA SCRIPT CODE 2
----------------------------------------------------------------------------------------------------------
<html>
<head>
<script type="text/javascript">
window.onload = function() {
var size = 5;
document.body.innerHTML = "<center>" + Array.apply(0, new Array(size)).map(function(_, i) {
return new Array((i + 1) * 2).join(" * ");
}).join("<br>") + "</center>";
}
</script>
</head>
<body>
</body>
</html>
----------------------------------------------------------------------------------------------------------
TRIANGLE IN C++
READ MORE:
http://www.codebind.com/cpp-tutorial/cpp-example-c-program-print-triangle-stars/
C++ CODE VIEWER

C++ shell

http://cpp.sh/
https://www.microsoft.com/net/learn/languages
-----------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
int main()
{
  int i,j,k;
  for(i=1; i<=5; i++)
    {
      for(j=4; j>=i; j--)
        {
          cout<<" ";
        }
      for(k=1; k<=(2*i-1); k++)
        {
          cout<<"*";
        }
      cout<<"\n";
    }
  return 0;
}
/*
OUTPUT:
    *
   ***
  *****
*******
*********
*/
------------------------------------------------------------------------------------------------------------






0 comments:

Post a Comment

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets