--> Bhaskara's Formula (beeCrowd- 1036) URI 1036 Solution C, Python | Alpha Codist

Search This Blog

Bhaskara's Formula (beeCrowd- 1036) URI 1036 Solution C, Python

Bhaskara's Formula beeCrowd 1036 URI 1036 Solution C Python problem solve solution solved coding Impossivel calcular discriminant sqrt r1 r2 x1 x2 1 2

Bhaskara's Formula

Bhaskara's Formula beeCrowd 1036 URI 1036 Solution C Python problem solve solution solved coding Impossivel calcular discriminant sqrt r1 r2 x1 x2 1 2


Read 3 floating-point numbers (double). Print the result with 5 digits after the decimal point. if it is impossible to calculate print the message "Impossivel calcular"

The formula is:

  1. Take input. 
  2. Calculate the value of discriminant(d) with the formula: b2-4ac.
  3. Next, if the value of discriminant(d) is less than or if the value of a is zero then print "Impossivel calcular".
  4. Else calculate the value of x1(R1) and x2(R2) with this formula: (-b±Ã–d)/2a. note that you need to calculate 2 values. One for plus and one for minus. And then print both values as said on that site.


The solution in C:


#include <stdio.h>

int main() {
    double a,b,c,R1,R2;
    scanf("%lf %lf %lf",&a,&b,&c);
    double D = (b*b)-(4*a*c);
    if(D<0){
        printf("Impossivel calcular\n");
    }
    else if(a==0){
        printf("Impossivel calcular\n");
    }
    else{
        R1 = (-b+sqrt(D))/(a+a);
        R2 = (-b-sqrt(D))/(a+a);
        printf("R1 = %0.5f\n",R1);
        printf("R2 = %0.5f\n",R2);
    }
    return 0;
}


The solution in Python:


import math;

a,b,c=map(float, input().split(" "))
d = ((b*b)-(4*a*c));
if d>=0:
    print("Impossivel calcular")
elif a==0:
    print("Impossivel calcular")
elif d>0:
    x1 = ((-b+math.sqrt(d))/(2*a))
    x2 = ((-b-math.sqrt(d))/(2*a))
    print(f"R1 = %0.5f\nR2 = %0.5f" % (x1,x2))

COMMENTS

Name

beeCrowd,11,C,10,Computer,9,Downloads,3,HTML,1,My Creation,2,Python,24,Python-Soft,1,Shooting,2,
ltr
item
Alpha Codist: Bhaskara's Formula (beeCrowd- 1036) URI 1036 Solution C, Python
Bhaskara's Formula (beeCrowd- 1036) URI 1036 Solution C, Python
Bhaskara's Formula beeCrowd 1036 URI 1036 Solution C Python problem solve solution solved coding Impossivel calcular discriminant sqrt r1 r2 x1 x2 1 2
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRPpxMu5dimkZBUVBCJsznsHQoSdA0exsng8wTWUPDBXzv-j4zQoL3shcRBQkui0787rcpQPjjLunfCO8UJTdj9gpAyF4Y7OZHE4w9z55aLs7SnuGdp8YrcTil34ptmNkGs4dBy5t4fUiGvnh9wzQOau6Kah8BxvrKNugX_I2mV4cs9APgUittx852Rw/w640-h422/1036.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRPpxMu5dimkZBUVBCJsznsHQoSdA0exsng8wTWUPDBXzv-j4zQoL3shcRBQkui0787rcpQPjjLunfCO8UJTdj9gpAyF4Y7OZHE4w9z55aLs7SnuGdp8YrcTil34ptmNkGs4dBy5t4fUiGvnh9wzQOau6Kah8BxvrKNugX_I2mV4cs9APgUittx852Rw/s72-w640-c-h422/1036.png
Alpha Codist
https://alphacodist.blogspot.com/2022/12/bhaskarasformula.html
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/2022/12/bhaskarasformula.html
true
7547834254111195316
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content