www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function to slive a quadratic equation

reply zvia <zviasch walla.co.il> writes:
Is it true?

import std.math;
import std.cstream;
import std.stdio;

void main()
{
   int a,b,c, result, result1, result2, mechane, mone=0, diskremin;
   char[] str;


    din.readf( "%d", &a);
    din.readf( "%d", &b);
    din.readf( "%d", &c);

   writefln("Enter parameter for quadratic equation: ");
   writefln("Enter a: ");
   din.readf( "%d", &a);
   writefln("Enter b: ");
   din.readf( "%d", &b);
   writefln("Enter c: ");
   din.readf( "%d", &c);

   writefln("\nThe mishvaa is: %dX^2+%DX+%d",a,b,c);

    if(a!=0)
    {
        diskremin = b*b-4*a*c;
        if(diskremin>=0)
        {
            mone = pow(diskremin,0.5);
        }

        mechane = 2*a;
        result1 = (double)((-b+mone)/mechane);
        result2 = (double)((-b-mone)/mechane);

        writefln("\nresult is: %d , %d",result1,result2);
    }
    else
    {
        writefln("\nresult is: %d",(double)(-c/b));
    }


}
Jan 31 2009
next sibling parent reply Chris R Miller <lordsauronthegreat gmail.com> writes:
zvia wrote:
 Is it true?
Well, void main will implicitly return 0 to the local operating system, so it must be!
 void main()
Feb 01 2009
parent reply zvia <zviasch walla.co.il> writes:
Is it true thr input way? what is din type (I didn't put its a declaration)?? 

Chris R Miller Wrote:

 zvia wrote:
 Is it true?
Well, void main will implicitly return 0 to the local operating system, so it must be!
 void main()
Feb 01 2009
parent reply Christopher Wright <dhasenan gmail.com> writes:
zvia wrote:
 Is it true thr input way? what is din type (I didn't put its a declaration)?? 
Thrinput's Way was discredited in the late 1700's by a German theologian named Albrecht Kirsch. It was already in decline due to its requirements of extreme asceticism; many scholars, most notably Dr. M. Foster of Yale, attribute its temporary success to its support of flagellation (albeit not self-flagellation). http://www.digitalmars.com/d/1.0/phobos/std_stream.html
Feb 01 2009
next sibling parent reply BCS <none anon.com> writes:
Hello Christopher,

 Thrinput's Way was discredited in the late 1700's by a German
 theologian named Albrecht Kirsch. It was already in decline due to its
 requirements of extreme asceticism; many scholars, most notably Dr. M.
 Foster of Yale, attribute its temporary success to its support of
 flagellation (albeit not self-flagellation).
 
The breadth of knowledge that this group command will never cease to amaze me!
Feb 01 2009
next sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
On Sun, Feb 1, 2009 at 4:02 PM, BCS <none anon.com> wrote:
 Hello Christopher,

 Thrinput's Way was discredited in the late 1700's by a German
 theologian named Albrecht Kirsch. It was already in decline due to its
 requirements of extreme asceticism; many scholars, most notably Dr. M.
 Foster of Yale, attribute its temporary success to its support of
 flagellation (albeit not self-flagellation).
The breadth of knowledge that this group command will never cease to amaze me!
It is complete bunkum XD
Feb 01 2009
prev sibling next sibling parent John Reimer <terminal.node gmail.com> writes:
Hello BCS,

 Hello Christopher,
 
 Thrinput's Way was discredited in the late 1700's by a German
 theologian named Albrecht Kirsch. It was already in decline due to
 its requirements of extreme asceticism; many scholars, most notably
 Dr. M. Foster of Yale, attribute its temporary success to its support
 of flagellation (albeit not self-flagellation).
 
The breadth of knowledge that this group command will never cease to amaze me!
Ask us the same questions in person and see how fast we answer. ;) -JJR
Feb 01 2009
prev sibling parent Chris R Miller <lordsauronthegreat gmail.com> writes:
BCS wrote:
 Hello Christopher,
 
 Thrinput's Way was discredited in the late 1700's by a German
 theologian named Albrecht Kirsch. It was already in decline due to its
 requirements of extreme asceticism; many scholars, most notably Dr. M.
 Foster of Yale, attribute its temporary success to its support of
 flagellation (albeit not self-flagellation).
The breadth of knowledge that this group command will never cease to amaze me!
Don't look at me, I'm just a screensaver!
Feb 01 2009
prev sibling parent John Reimer <terminal.node gmail.com> writes:
Hello Christopher,

 zvia wrote:
 
 Is it true thr input way? what is din type (I didn't put its a
 declaration)??
 
Thrinput's Way was discredited in the late 1700's by a German theologian named Albrecht Kirsch. It was already in decline due to its requirements of extreme asceticism; many scholars, most notably Dr. M. Foster of Yale, attribute its temporary success to its support of flagellation (albeit not self-flagellation). http://www.digitalmars.com/d/1.0/phobos/std_stream.html
That's certainly one way to answer such a question. -JJR
Feb 01 2009
prev sibling parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
On Sat, Jan 31, 2009 at 8:21 PM, zvia <zviasch walla.co.il> wrote:
 Is it true?
I have *no* idea what you're asking. What is your question?
Feb 01 2009