Question: instead of adding each number Manuel like this: 1 2 3 4 5 6 7 8 9. Is it possible to make a code that keeps adding 1 to the number and how?
10/30/2018 8:34:51 AM
Alexander R. Storr-Hansen18 Answers
New AnswerI saw this on discord lol. Okay, so what you need to do is provide me with sample input and sample output.
So basically, what do you want to enter as input and what do you want to get as a result?
Sure, just use a loop. <?php for($i=1;$i<=10;$i++){ //increase number by one until 10 echo $i; //print number echo " "; //print space } ?> output: 1 2 3 4 5 6 7 8 9 10
A simple For loop that keeps incrementing by 1 should do. In Lua the code would be the following: for i = 1, 100 do print(i) end
You can embed php in html. Or you can do it with Javascript. Please have a look at the teaching section there the basics of these languages is explained
This would be the code if you want it in HTML. Write the following in Javascript: document.write("<p style='font-weight:bold'>"); for(i=1;i<=100;i++) { document.write(i); document.write("<br/>") } document.write("</p>");
what im really trying to is make a select property with numbers from 1900 up to 2018 to a registration for age. just gonna learn it from sololearn them self. thanks for helping👍💪
just wanted to get a fast answer lol 😂🤣. aaaaaand. i have no idea what you are taking about
just want to have the first number to be one and the last number to be 100 without whriting it manuel
sorry man i dont think you understand. instead of whriting <p> 1 2 3 4 5.... 100 </p> can you just whrite a code that does that for you?
matthias okay thanks for the help. im quick trying Aatif’s solution if it works it works. if it do not work somethings wrong with me and im just gonna wait until sololearn learns me how to do 😂🤣
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message