Saturday, 6 July 2013

more on logic using for loop


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
We want like this
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1

Few days back I  brought vegetables.
My son is playing with tomatoes; he asked what these dad are. I replied to him tomatoes he said ohhh tomato

At that moment I have given tomatoes like this, and he arranged very neatly.

First time I given one tomato
Second time two tomatoes
Third time three tomatoes
Fourth time four tomatoes
Fifth time five tomatoes



he arranged like below




Logic is below

Copy start from below 

<html>
<body>

<script type="text/javascript">

var dad,son;

for(dad=1;dad<=5;dad++)
           
             {

                       for(son=1; son<=dad;son++)

                                  {
                                   
                          document.write("1");
                                  }

                            document.write("<BR>");
}



</script>

</body>
</html>

-----------------------copy ends above--------------------------------------------------
Understand this:

dad condition is 5 [dad<=5] rounds, for every round dad will increase

son listen dad voice he did not ask more tomatoes so son condition is[son<=dad]


Starts from hear:


First time dad given one tomato like this [dad=1;dad<=5]

above dad variable contains 1 tomato [assume in dad hand 1 tomato and condition is satisfied 1<=5]

now dad  put 1 tomato in son hand 

now sun part

now sun variable  contains 1 tomato

becz he listen dad voice like this son<=dad[1<=1]

in first row he put tomato on floor like this 

row 1--->.


next second round

dad variable contains 2 tomatoes why dad++[dad incremented, dad taken two tomatoes second round]

and condition satisfied dad<=5[2<=5]

now son part

dad given first tomato for second row

sun variable contains 1 tomato in his hand [sun=1]
and condition is satisfied 1<=dad[1<=2]

row 2---->.

 next son++[son incremented] son excepted second tomato
 taken second tomato from father, condition is satisfied son<=dad[2<=2]

he put second tomato on floor now row 2 contains two tomatoes
  

row 2---->..

like that sun continued 

Third time three tomatoes
Fourth time four tomatoes
Fifth time five tomatoes

like that son arranged see how sweetly he arranged

in place of tomato you can assume 1

now output is 

1
11
111
1111
11111

------------------------THANK YOU FOR ALL----------------------------------------

This time i am expecting child[son],He is womb of her mother. Please bless me.



No comments:

Post a Comment