What is wrong with this program?

Discussion in 'Ruby' started by Prateek Agarwal, Aug 7, 2009.

  1. Prateek Agarwal, Aug 7, 2009
    #1
    1. Advertising

  2. Prateek Agarwal

    pharrington Guest

    On Aug 6, 11:51 pm, Prateek Agarwal <> wrote:
    > I don't understand what is wrong with this program. It gives an error:
    > 'findarea' undefined local variable or method 'area_of_triangle'
    > Both 'findarea' and 'area_of_triangle' are clearly defined.
    >
    > Attachments:http://www.ruby-forum.com/attachment/3933/Q3a1.rb
    >
    > --
    > Posted viahttp://www.ruby-forum.com/.


    Prateek,

    You post alot of basic troubleshooting questions on the list. This
    really is something you need to learn to do on your own when
    programming, as no one gets their code right the first time through
    the keyboard.

    But for this, a simple Ctrl+F through your own code will give you the
    answer.
     
    pharrington, Aug 7, 2009
    #2
    1. Advertising

  3. Prateek Agarwal

    Eric Hodel Guest

    On Aug 6, 2009, at 21:10, pharrington wrote:
    > On Aug 6, 11:51 pm, Prateek Agarwal <> wrote:
    >> I don't understand what is wrong with this program. It gives an
    >> error:
    >> 'findarea' undefined local variable or method 'area_of_triangle'
    >> Both 'findarea' and 'area_of_triangle' are clearly defined.
    >>
    >> Attachments:http://www.ruby-forum.com/attachment/3933/Q3a1.rb
    >>
    >> --
    >> Posted viahttp://www.ruby-forum.com/.

    >
    > Prateek,
    >
    > You post alot of basic troubleshooting questions on the list. This
    > really is something you need to learn to do on your own when
    > programming, as no one gets their code right the first time through
    > the keyboard.
    >
    > But for this, a simple Ctrl+F through your own code will give you the
    > answer.


    Also, seems to be homework based on the filename.
     
    Eric Hodel, Aug 7, 2009
    #3
  4. Prateek Agarwal

    Sijo Kg Guest

    Hi
    two errors there

    1 area_of_triange=Math.sqrt(s*(s-side_a)*(s-side_b)*(s-side_c))
    spelling mistake in area_of_triange
    2 return area
    area is not defined


    Sijo
    --
    Posted via http://www.ruby-forum.com/.
     
    Sijo Kg, Aug 7, 2009
    #4
  5. Prateek Agarwal

    pharrington Guest

    On Aug 7, 1:33 am, Sijo Kg <> wrote:
    > Hi
    >    two errors there
    >
    > 1  area_of_triange=Math.sqrt(s*(s-side_a)*(s-side_b)*(s-side_c))
    >     spelling mistake in area_of_triange
    > 2 return area
    >     area is not defined
    >
    > Sijo
    > --
    > Posted viahttp://www.ruby-forum.com/.


    One of my friends during conversation:

    what i have learned from my time at hms both as a tech and as a mentor
    that getting answers is a drug. you get addicted to it. if you find
    some venue through which you happen to get a bunch of answers, be it a
    forum or list or nate coffield, you will abuse it until it turns on you
     
    pharrington, Aug 7, 2009
    #5
  6. Prateek Agarwal

    balbao Guest

    Hey,

    There are couple of things to be mended in the function "findarea".

    They are

    (i) "area_of_segment=(4.0/3)*area_of_triangle" But in the prev line,
    you have declared the variable as "area_of_triange". "L(l) is
    missing."

    (ii) You're returning the variable "area" from the function to the
    main block. But there is no such variable in the function. Guess it
    has to be "area_of_segment".

    This should work now.

    - Balbao.


    On Aug 7, 9:06 am, pharrington <> wrote:
    > On Aug 6, 11:51 pm, Prateek Agarwal <> wrote:
    >
    > > I don't understand what is wrong with this program. It gives an error:
    > > 'findarea' undefined local variable or method 'area_of_triangle'
    > > Both 'findarea' and 'area_of_triangle' are clearly defined.

    >
    > > Attachments:http://www.ruby-forum.com/attachment/3933/Q3a1.rb

    >
    > > --
    > > Posted viahttp://www.ruby-forum.com/.

    >
    > Prateek,
    >
    > You post alot of basic troubleshooting questions on the list. This
    > really is something you need to learn to do on your own when
    > programming, as no one gets their code right the first time through
    > the keyboard.
    >
    > But for this, a simple Ctrl+F through your own code will give you the
    > answer.
     
    balbao, Aug 7, 2009
    #6
  7. Prateek Agarwal

    Ilan Berci Guest

    pharrington wrote:

    >
    > what i have learned from my time at hms both as a tech and as a mentor
    > that getting answers is a drug. you get addicted to it. if you find
    > some venue through which you happen to get a bunch of answers, be it a
    > forum or list or nate coffield, you will abuse it until it turns on you


    Ya ya.. I can quit any time .. just give me some more answers please..

    ilan
    --
    Posted via http://www.ruby-forum.com/.
     
    Ilan Berci, Aug 7, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VisionSet

    what's wrong in this program

    VisionSet, Sep 24, 2004, in forum: Java
    Replies:
    12
    Views:
    558
    Thomas G. Marshall
    Sep 28, 2004
  2. Replies:
    7
    Views:
    424
  3. Matthew
    Replies:
    7
    Views:
    744
    Priscilla Walmsley
    Jan 7, 2005
  4. jose luis fernandez diaz

    why this program is wrong on Tru64 OS ?

    jose luis fernandez diaz, Nov 25, 2003, in forum: C++
    Replies:
    2
    Views:
    436
    Stephan Br?nnimann
    Nov 26, 2003
  5. Replies:
    5
    Views:
    1,605
Loading...

Share This Page