| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 13

1. What is the output of the given code? m=0 loop do print "ruby" m+=1 break if m==5 end

Correct Answer is : rubyrubyrubyrubyruby

2. What is the output of the given code? m=0 loop do puts m*10 m+=1 break if m==5 end

Correct Answer is : 0 10 20 30 40

3. What is the output of the given code? m=0 loop do puts 101 m+=1 break if m==5 end

Correct Answer is : 101 101 101 101 101

4. What is the output of the given code? m=5 loop do m-=1 break if m==0 end

Correct Answer is : Nil

5. While loop checks the condition and the loop keeps on running till the condition is true, it stops when the condition becomes false.

Correct Answer is : TRUE

6. What is the output of the given code? counter = 1 while counter < 11 puts counter counter = counter + 1 end

Correct Answer is : Prints the number from 1 to 10

7. What is the output of the given code? counter = true while counter !=false puts counter end

Correct Answer is : Infinite loop

8. What is the output of the given code? i = 0 while i < 5 puts i i=(i+1)**2 end

Correct Answer is : 36529

9. What is the output of the given code? a=5 b=15 while a&&b puts a+b end

Correct Answer is : Infinite loop

10. What is the output of the given code? a=5 b=15 while b>a puts a*(b-a) while a>b a+=1 b-=1 end end

Correct Answer is : Infinite loop

11. What is the output of the given code? i = 3 while i > 0 do print i i -= 1 end

Correct Answer is : 321

12. What is the output of the given code? i = 50 while i > 25 do print 50/i i -= 1 end

Correct Answer is : 1111111111111111111111111

13. What is the output of the given code? a = 5 b=10 while a
Correct Answer is : 50 56