Connecting Tech Pros Worldwide Forums | Help | Site Map

C programming

Newbie
 
Join Date: Oct 2009
Posts: 3
#1: Oct 21 '09
Can anyone help me with the following question on programming please?

A second-degree polynomial in x is given by the expression ax2+bx +c, where a, b, and c are known numbers and a is not equal to zero. Given the values of a, b, c, and x, write a function named poly_two(a, b, c, x) that computes and returns the value of the second-degree polynomial if all the given values are passed by value. Make sure your function poly_two(a,b,c,x) is called from the main() and that it correctly returns the value to main(). The function prototype for poly_two() function must be written in the main() function in such a way that you use printf() to display the value returned. Test the function by passing various data to it.

Needs Regular Fix
 
Join Date: Jul 2008
Posts: 386
#2: Oct 21 '09

re: C programming


It's not a question, it's a homework. It doesn't even contain a single question mark.
Newbie
 
Join Date: Oct 2009
Posts: 3
#3: Oct 21 '09

re: C programming


It's not a homework... is just a question a picked from the past papers that were written and i attempted to lots of them but i got stuck on this one. You can even give me a small blief on how to go about it...
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 833
#4: Oct 21 '09

re: C programming


You are also asked to test the program. I suggest you start by preparing your test cases. Make a table of input values a,b,c,x and expected return values. Pay attention to how you computed the expected return value for each input combination -- it should serve as a hint for how to organize the computer program.
Newbie
 
Join Date: Oct 2009
Posts: 3
#5: Oct 21 '09

re: C programming


That explained alot... I will defenitly do that and see how far i can go.
Familiar Sight
 
Join Date: Jan 2007
Posts: 193
#6: Oct 22 '09

re: C programming


@ newb16
Quote:
It doesn't even contain a single question mark.
yes it does
Quote:
Can anyone help me with the following question on programming please?
If you know the formula for the solution you will realise that b^2 must be > 4*a*c.
This precondition must be attained in order to obtain the roots. Your code should address this precondition in some way to avoid trying to get the sqrt of a negative.
Note you are not being asked for the value of the roots just to substitute values for a,b,c and x so that if a=1,b=2,c=3 and x=4 the value of the polynomial would be 27.
Needs Regular Fix
 
Join Date: Jul 2008
Posts: 386
#7: Oct 22 '09

re: C programming


Quote:

Originally Posted by whodgson View Post

@ newb16
yes it does

"the following question" - i.e. what follows "can you help me with... ?" sentence still doesn't.

Quote:
If you know the formula for the solution you will realise that b^2 must be > 4*a*c.
This precondition must be attained in order to obtain the roots.
Why does the code need to obtain the roots?
Reply