Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,382 members, 7,954,545 topics. Date: Friday, 20 September 2024 at 09:48 PM |
Nairaland Forum / Science/Technology / Programming / Help Convert This WHILE Loop Into A FOR Loop (1991 Views)
Javascript - For Loop / Help With Python Program (simple While Loop) / Programming Challenge: Convert String to Json with a Loop (2) (3) (4)
Help Convert This WHILE Loop Into A FOR Loop by Talk2bryant(m): 8:51pm On Jul 11, 2015 |
Int i= 1; Int sum = 0; while (sum < 10) { sum = sum + i; i++; } |
Re: Help Convert This WHILE Loop Into A FOR Loop by omoelu1(m): 10:43pm On Jul 11, 2015 |
Goodluck!!! |
Re: Help Convert This WHILE Loop Into A FOR Loop by hisabimbola(m): 10:51pm On Jul 11, 2015 |
This question sounds funny, guess that's why you got no response, but either ways
Wrote it in JS, but you should be able to convert it |
Re: Help Convert This WHILE Loop Into A FOR Loop by Nobody: 11:26pm On Jul 11, 2015 |
My own simple answer(after girraffing some of the codes above) is: In Java: Int sum=0; In JavaScript: sum=0; In PHP: $sum=0; I have already used my eyes to debug it - it will work. . . . 1 Like |
Re: Help Convert This WHILE Loop Into A FOR Loop by fattbabakay(m): 9:25am On Jul 12, 2015 |
dhtml18:Guruuuuuuuu!!! |
Re: Help Convert This WHILE Loop Into A FOR Loop by Damey2011(m): 9:14am On Jul 13, 2015 |
dhtml18: The Increment is applicable to the integer i.. so the for line is What I see about the code is just printing sum from 0-9.. but the essence of the int = 1 is to make is start from 1- 10 instead cos the computer is programmed to start counting from 0 for a reason I dont know |
Re: Help Convert This WHILE Loop Into A FOR Loop by eDoc: 10:41am On Jul 13, 2015 |
if i understand your code well,this is in python. i had to study other code above, As i is incrementing from 1 to whatever,sum is adding it's self to the present state of i.
|
(1) (Reply)
Heeeeeeeeeeelp Pls / A Challenge Facing Programming In Nigeria / What Is The Highest Number Output By This Function...
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |