[img]http://img19.imageshack.us/img19/9384/f5.JPG[/img]

#include <stdio.h>
#include <math.h>
void main()
{
double a,b,c,disc,x1,x2;
printf("To find the roots of a quadriatic equation with real roots\n")
disc=b*b-4*a*c
if(disc<0)
printf("The roots are complex",disc);
if(disc>=0)
printf("-b+sqrt(disc)/2a",x1);
printf("-b-sqrt(disc)/2a",x2);


This is what i wrote, i know it is missing alot
but I really dunno how to do it, so can anyone help me to do the rest
so it can run well

Hello,

To start with, when you declare variables, initialize them right away:

double a = b = c = disc = x1 = x2 = 0.0;

Next, you will need to use cin or scanf to read the data into variables.

You will also need to check your operator precidence. Example:

4 * 3 / 4 + 6 = 9

4 * 3 / (4 + 6) = 4 * 3 / 10 = 1.2

Your disc equation will need help.

Let us know how it works.

Christian

double a = b = c = disc = x1 = x2 = 0.0;

It uses equal? i dun get it?

scanf all variables?

Hello,

double a = b = c = disc = x1 = x2 = 0.0;

declares all of those variables as double values, and then assigns them a value of zero.

Remember that in C, = is the assign operator, and == is the equals operator.

scanf(%d, variable); scans in an integer
scanf(%lf, variable); scans in a floating double number

You are going to need to read your C or C++ book to find out how to set these things up properly, and gain a greater understanding of what you are trying to do.

Give it a shot.

Christian

Please dont post such huge pics,my connection is slow at the best and it take a long time to download huge pic :-(

Hello , this was my homework in the past
i hope it will help you

Please dont post such huge pics,my connection is slow at the best and it take a long time to download huge pic :-(

sorry about that

Hello , this was my homework in the past
i hope it will help you

urs is too hard for me

This is my project thats due tomorrow
can someone do the rest for me?
i am lack of time now....
coz i got my final tomorrow too

This is my project thats due tomorrow
can someone do the rest for me?
i am lack of time now....
coz i got my final tomorrow too

they dont do others homework here, your going to have to do it, best that you can hope for is a direction to go in, and maybe some hints, but you cant expect someone to just write all the code for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.