Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,261 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,544 people online right now. Registration is fast and FREE... Join Now!




Homework Help Needed for Quadratic Formula

 
Reply to this topicStart new topic

Homework Help Needed for Quadratic Formula

paingpyi
14 Dec, 2006 - 12:21 PM
Post #1

New D.I.C Head
*

Joined: 14 Dec, 2006
Posts: 2


My Contributions
Write a complete C program to
determine the roots of the
quadratic equation
ax2+bx+c = 0
Using the well-known quadratic formula.
Following is the image of the formula to be used and hints.
IPB Image

I've written this code but it's not complete. I don't understand that math concept.
Anyone please help me! Thanks

CODE
#include "stdio.h"
#include "math.h"

int main()
{
float a=3;
float b=6;
float c=3;

float x;

x = ((-b) + sqrt(b*b)-(4*a*c))/(2*a);

printf("x is %f",x);


return 0;
}





Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

gordo
RE: Homework Help Needed For Quadratic Formula
14 Dec, 2006 - 09:39 PM
Post #2

New D.I.C Head
Group Icon

Joined: 7 Dec, 2006
Posts: 34


Dream Kudos: 25
My Contributions
Your sqrt() coding is incorrect.

sqrt( b*b -4*a*c) is ok.
You were pretty close though. I think U should get it now.

Don't forget, you need 2 answers, not 1. (hint)
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Homework Help Needed For Quadratic Formula
14 Dec, 2006 - 09:54 PM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
This code snippet submitted by another member may help you with your problem. It is written in C++, but you should get the idea.
http://www.dreamincode.net/code/snippet391.htm

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 06:55PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month