0% found this document useful (0 votes)
28 views1 page

PT Bac 2

This C++ code is solving a quadratic equation. It takes in coefficients a, b, and c from the user, then calculates the discriminant delta. Based on the values of a, b, c, and delta, it determines whether the equation has no solutions, one solution, or two solutions, and outputs the appropriate result.

Uploaded by

Nguyen Tuan Hung
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

PT Bac 2

This C++ code is solving a quadratic equation. It takes in coefficients a, b, and c from the user, then calculates the discriminant delta. Based on the values of a, b, c, and delta, it determines whether the equation has no solutions, one solution, or two solutions, and outputs the appropriate result.

Uploaded by

Nguyen Tuan Hung
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include<iostream.h> #include<conio.h> #include<math.

h> main() { float a, b, cout<<"Nhap cout<<"Nhap cout<<"Nhap

c, a: b: c:

x, "; "; ";

delta; cin>>a; cin>>b; cin>>c;

if(a == 0) { if(b == 0) { if(c == 0) cout<<"Phuong trinh co vo so nghiem"; else cout<<"Phuong trinh vo nghiem"; } else cout<<"Phuong trinh co nghiem duy nhat: x = "<<(c)/b; } else { delta = b*b - 4*a*c; if(delta < 0) cout<<"Phuong trinh vo nghiem"; else if(delta == 0) cout<<"Phuong trinh co nghiem kep: x1 = x2 = "<<(-b)/(2*a); else { cout<<"Phuong trinh co hai nghiem phan biet:"; cout<<"\nx1 = "<<(- b - sqrt(delta))/(2*a); cout<<"\nx2 = "<<(- b + sqrt(delta))/(2*a); } } getch(); }

You might also like