Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0

Answer Posted / shariful islam

#include<stdio.h>
#include<math.h>

int main(){
float a,b,c;
float d,root1,root2;

printf("Enter quadratic equation in the format ax^2+bx+c: ");
scanf("%fx^2%fx%f",&a,&b,&c);

d = b * b - 4 * a * c;

if(d < 0){
printf("Roots are complex number.
");

return 0;
}

root1 = ( -b + sqrt(d)) / (2* a);
root2 = ( -b - sqrt(d)) / (2* a);
printf("Roots of quadratic equation are: %.3f , %.3f",root1,root2);

return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what will the preprocessor do for a program?

1002


How can variables be characterized?

2123


What are the features of the c language?

1035


What is pointer in c?

1137


what are bit fields? What is the use of bit fields in a structure declaration?

2039


Why is this loop always executing once?

996


What is difference between arrays and pointers?

1010


Stimulate calculator using Switch-case-default statement for two numbers

2920


Do you know the purpose of 'register' keyword?

964


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

2081


why return type of main is not necessary in linux

2042


What are the advantages of external class?

1001


write a program to create a sparse matrix using dynamic memory allocation.

4831


What is function in c with example?

1085


What is memcpy() function?

1046