Authour:I will teach you courses online
C Language | C++ | Asp.net | VB.net | Oracle | Hardware and Networking | MCSE |
Contact: | Name: Shrinivas | Mobileno:9703619391 (india) |
E-mail: vas.shrinivas002@gmail.com |
To day friend ivan. Asked below prog why cannot u try this.
1
121
1221
12221
122221
Program logic Is hear.
----------------------------start copy from below--------------------------------------------------
<html>
<body>
<script type="text/javascript">
var i,j;
for(i=1;i<=5;i++)
{
document.write("1");
for(j=1;j<i;j++)
{
document.write("2");
}
if(i>1)
{
document.write("1");
}
document.write("<BR>");
}
</script>
</body>
</html>
---------------end of copy above---------------
I want like this
1
121
1221
12221
122221
Child observed 1 is common frent and back 1 .....1
that's why we added first 1 at starting of program and second 1added ending of program like this
document.write("1")
-------
----
-----
-----
document.write("1");
after completed this. It should come next line that's why i used document.write("<BR>");
about 2:
Number 2 is added from second row
you cannot see no 2 first row , added from second row that's why i used [j<i;]
Detailed:
1
121---2 came 1 time
1221---2 came 2 times
12221---2 came 3 times
122221---2 came 4 times all these acheived with this [j<i]
document.write("2");
first iteration 2 cannot print becz [j<i]---1<1
second iteration 2 will print only one time becz [j<i]---1<2 acheived with document.write("2");
next j wil increment becz of 2<2 now exit from j loop sooooooo on.....
observe this:
for(j=1;j<i;j++)
{
document.write("2");
}
Authour:I will teach you courses online
C Language | C++ | Asp.net | VB.net | Oracle | Hardware and Networking | MCSE |
Contact: | Name: Shrinivas | Mobileno:919703619391 | E-mail: vas.shrinivas002@gmail.com |
You can utilize my programs in Database also[ORACLE(PLSQL)] ,MSQLSERVER.
Not only in c++,Net