Tuesday 26 January 2016

Solution of URI 1036 :: Bhaskara's Formula


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    double A,B,C,d,e,f,g;
    scanf ("%lf%lf%lf", &A,&B,&C);
    d=B*B-4*A*C;
    e=pow(d,.5);
    if(d<0||A==0)
        printf ("Impossivel calcular\n");
    else
    {
        f=(-B+e)/(2*A);
        g=(-B-e)/(2*A);
        printf ("R1 = %.5lf\n",f);
        printf ("R2 = %.5lf\n",g);
    }
    return 0;
}

5 comments:

  1. why use .5 for divide with d??

    ReplyDelete
  2. why you take 3 double data type but in question they said float type of data

    ReplyDelete
  3. because u need to put atleast 5 float numbers after point ..so u need to use double instead of float numbers..

    ReplyDelete

Note: only a member of this blog may post a comment.