Problem with my program, no output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hazelfogbeam
    New Member
    • Nov 2006
    • 1

    Problem with my program, no output

    guys i tried constructing a programe and did but the problem when i run it the screen disappears and no output is presented. I am posting in the question as well as the script which i wrote,please send a reply to me abt it.
    question is:
    using if statement,to print the roots of a quadratic equation,given the condition as follows:
    IF ROOTS
    b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a

    b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)

    b*b-4*a*c<0 roots are imaginary

    script which i had typed:
    #include<iostre am.h>
    #include<conio. h>
    #include<math.h >
    void main()
    {
    clrscr();
    float a,b,c,r1,d,r2,e ;
    cout<<"\n enter the values of three no.s";
    cin>>a>>b>>c;
    d=b*b-4*a*c;
    e=sqrt(d);
    r1=(-b+e)/(2*a);
    r2=(-b+e)/(2*a);
    cout<<"\n root1="<<r1;
    cout<<"\n root2="<<r2;
    if (d>0)
    cout<<"\n "<<r2;
    else
    {
    if (d==0)
    cout<<"\n roots are equal"<<r1;
    }
    if (d<0)
    cout<<"\n roots are imaginary";
    getch();
    }
  • sudhirlko2001
    New Member
    • Nov 2006
    • 2

    #2
    Remove GetCh()

    and try to get input with ALT+F5


    Originally posted by hazelfogbeam
    guys i tried constructing a programe and did but the problem when i run it the screen disappears and no output is presented. I am posting in the question as well as the script which i wrote,please send a reply to me abt it.
    question is:
    using if statement,to print the roots of a quadratic equation,given the condition as follows:
    IF ROOTS
    b*b-4*a*c>0 {-b(+/-)sqrt(b*b-4*a*c)}/2*a

    b*b-4*a*c=0 {-b/2*a} (msg=roots are equal)

    b*b-4*a*c<0 roots are imaginary

    script which i had typed:
    #include<iostre am.h>
    #include<conio. h>
    #include<math.h >
    void main()
    {
    clrscr();
    float a,b,c,r1,d,r2,e ;
    cout<<"\n enter the values of three no.s";
    cin>>a>>b>>c;
    d=b*b-4*a*c;
    e=sqrt(d);
    r1=(-b+e)/(2*a);
    r2=(-b+e)/(2*a);
    cout<<"\n root1="<<r1;
    cout<<"\n root2="<<r2;
    if (d>0)
    cout<<"\n "<<r2;
    else
    {
    if (d==0)
    cout<<"\n roots are equal"<<r1;
    }
    if (d<0)
    cout<<"\n roots are imaginary";
    getch();
    }

    Comment

    • sivadhas2006
      New Member
      • Nov 2006
      • 142

      #3
      Hi,

      Can I know which editor you are using for progamming?

      Regards,
      M.Sivadhas.

      Comment

      • momotaro
        Contributor
        • Sep 2006
        • 357

        #4
        add this to the end of u r program:
        Code:
        scanf("%d", &x);
        ps: x is your variable that u should declare!

        Comment

        Working...