On Tue, Feb 11, 2014 at 11:20 AM, Jaimin Pandya <lists / ruby-forum.com> wrote:
> First I done program like Write a program using Ruby and Print 1 to 10.
> This program
>
> I solved as follow:
>
> x = 0
> while x <= 10
>   puts x
>   x = x + 1
>   end
>
> Now I want to do another program. I give program statement as follow.
>
> My program statement is Write a program using Ruby ask a number, and
> Print 1 up to number.
>
> I solved this program by following :
>
>     x = 0
>     while x <= 10
>        if x.class == Fixnum
>         puts x
>         end
>        x = x + 1
>        end
>
> But this solution of program is wrong.
>
> So How to solve this program? Please help me on this.

What you need to do is to change the 10 in your first program by a
number entered by the user. So look into Kernel#gets
(http://ruby-doc.org/core-2.1.0/Kernel.html#method-i-gets) and how to
convert what the user enters into a number String#to_i
(http://ruby-doc.org/core-2.1.0/String.html#method-i-to_i), and you
need a second variable to store this number and check x against it.

Hope this gets you in the right direction,

Jesus.