Created
April 29, 2021 07:25
-
-
Save btechmag/69f1ec719d321d25c94c51bd80f1fda2 to your computer and use it in GitHub Desktop.
C Program to print the roots of integers using Bhaskara's formula.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
//Program to print the roots of numbers using Bhaskara's formula | |
double a, b, c, temp; | |
printf("Input the first number: "); | |
scanf("%lf", &a); | |
printf("Input the second number: "); | |
scanf("%lf", &b); | |
printf("Input the third number: "); | |
scanf("%lf", &c); | |
temp = (b * b) - (4 * a * c); | |
if(temp > 0 && a != 0) | |
{ | |
temp = sqrt(temp); | |
printf("Root1 = %.3lf ", (-b + temp) / (2 * a) ); | |
printf("\nRoot2 = %.3lf ", (-b - temp) / (2 * a)); | |
} | |
else | |
{ | |
printf("Impossible to find the roots"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment