Problem with nested while do


#1

Hallo,
I am new to Ruby and I can’t solve this Problen.

I’ve got an Array w with 100 Elements called “w”.
I want to divide the array with 1…100 divisors.

i = 0
j = 1.0

w.each do |i|

while j <= 100.0 do

   print i/j,  ", "


   j +=1.0

end

end

but it’s not working.
Only the first Element of the Array is divided with
the hundred divisors.

I’d be very grateful for help.
Martin


#2

you need to declare “j” inside the “each” loop. By declaring it at the
top, you’re reaching j == 100, but you never set it back to 1.


#3

You never reset the value of j to 0, and as such, your inner loop
condition is never true after the first run. Assigning j = 0; in the
outer loop afterward should fix it.
http://www.besanttechnologies.com/training-courses/java-training
|
http://www.besanttechnologies.com/training-courses/android-training-institute-in-chennai


#4

C programming allows to use one loop inside another loop.

http://www.hackingmind.com/hacking-tips-to-prevent-a-ddos-attacks/


#5

Swati Sharma wrote in post #1180553:

C programming allows to use one loop inside another loop.

http://www.hackingmind.com/hacking-tips-to-prevent-a-ddos-attacks/

Very happy to see this blog. Gives a wonderful information with coded
explanaion. Thank you for this blog. very useful to me.
Android Training in
Chennai


#6

very helpful blog to the learners like me thanks a lot…Best
Selenium Training in Chennai | Selenium
Jobs


#7

really nice and helpful aricle to me

selenium
training in chennai | selenium
training institute in chennai
| Android
training in chennai | android
training


#8

thanks for the answers,

at the moment I haven’t the time to follow it up, but I think my
question is solved

mawgaw


#9

Wow. cool post. I’d like to write like this too – taking time and real
hard work to make a great article… but I put things off too much and
never seem to get started. Thanks though. http://supersmashflash-2.com
http://bloonstowerdefense5game.com


#10

I want you to thank for your time of this wonderful read!!! I definately
enjoy every little bit of it and I have you bookmarked to check out new
stuff of your blog a must read blog!
http://wordcookiesgame.com/
http://hillclimbracing-2.com/
http://fivenightsatfreddys-4.com/


#11

FITA is the best training institute for Android Training in Chennai.
Android Course in Chennai offers the well trained MNC professionals as
trainers. Android Training institute in Chennai offers the placements in
top IT Companies. We have trained more than 10,000+ students from 125+
IT Courses. We are providing the unique teaching methodology. Enroll for
the demo class.
Call Us:@9841746595
http://www.fitaacademy.com/courses/android-training-in-chennai/


#12

Hey,

you can solve the issues by contact our software trainers. Make sure,
They will easily all your programming problems.

http://sysacad.in/ |
http://sysadmintechnology.com/portfolio-view/red-hat-linux-training-in-chennai/


#13

Hey,

you can solve the issues by contact our software trainers. Make sure,
They will easily all your programming problems.
http://www.globaltrainingbangalore.com


#14

The reason your inner loop only executes once is because you initialize
j to 0 outside the loop and then never reset it again. After it runs the
first time the value of j is 10. It will never be less than 10 again.

A better way to do this is to use a for loop:

for (int i = 0; i < 10; i++){
printf(“i:%i\n”, i);
for (int j = 0; j < 10; j++){
printf(“j:%i\n”, j);
}
}
It also makes the code look cleaner.

https://www.gangboard.com/software-testing-training/selenium-training


#15

http://www.orangetechnomind.com

you need to increase i value as like j value, otherwise it use same
value

http://www.orangetechnomind.com/java-training-institute-in-chennai

http://www.orangetechnomind.com/android-training-chennai


#16

Check out this place to know more about it https://webdschool.com/graphic-design-courses-in-chennai.html