Hi All,
I am new to RUBY. Please help me in solving the below problem.
I have a c code and I am trying to do the same in RUBY.
for(int i = 0; i < 10;i++)
{
for(int j = 0; j< 5; j++)
{
if(i == j)
{
printf("%d - its J value\n",j);
i++;
}
}
printf("%d - its I value\n",i);
}
Above is my C code. The output of above code is:
0 - its J value
1 - its J value
2 - its J value
3 - its J value
4 - its J value
5 - its I value
6 - its I value
7 - its I value
8 - its I value
9 - its I value
I want to do the same in RUBY. I have written following script
(0..9).each do |i|
(0..5).each do |j|
if( i == j)
puts "#{j} J Value"
end
end
puts "#{i} I Value"
end
But its not giving the desired output. Please suggest me how to achieve
the above output using RUBY script.
Thanks in advance.
Regards,
Nag.
···
--
Posted via http://www.ruby-forum.com/.