What is wrong with this program?

  • Thread starter Prateek Agarwal
  • Start date
P

pharrington

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

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.
 
E

Eric Hodel

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.
 
S

Sijo Kg

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
 
P

pharrington

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

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
 
B

balbao

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.
 
I

Ilan Berci

pharrington said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top