Monday, 8 June 2015
Today I learnt about for loops which is is just a different kind of loop and the way it works is you need 3 pieces of information a starting value an ending value and how much you want to increment it by. here I made a line of code where it starts at 1 ends at 10 and goes up by 1. http://pastebin.com/7xwz0T8H if I break down the code and explain it for(int x = 1; x < 10; x++;) int x = 1; is the starting value x < 10; means to keep going until it hits 10 and x++; means add 1 every time I could also put x+=1; and it would do the same thing. http://gyazo.com/089af4ef8671bf15e94b09ef855c38c1
here is another one where it goes up by two and stops before it gets to 20 http://pastebin.com/Z3m3zkHN this is very simple yet very useful
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment