0% found this document useful (0 votes)
24 views3 pages

Quadratic Calculator Team 5

The team aims to define the value of x for the quadratic equation √ using C++. The code takes in coefficients a, b, and c from the user, calculates the determinant, and determines if the roots are real and different, real and same, or complex. It then displays the appropriate root(s) of the quadratic equation.

Uploaded by

Awi Romx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Quadratic Calculator Team 5

The team aims to define the value of x for the quadratic equation √ using C++. The code takes in coefficients a, b, and c from the user, calculates the determinant, and determines if the roots are real and different, real and same, or complex. It then displays the appropriate root(s) of the quadratic equation.

Uploaded by

Awi Romx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

TEAM 5

NUR ZAWAWI ZULKIFLEE

ADILAH MASRI

FARRAH ATIQAH DZAHIR

ZAHURA

SUHADAH ELIAS

ZULHAFIZ

OBJECTIVE
-

To define the value of x


Where ,

Using Microsoft studio c++


Here the code (INPUT)
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b, c, x1, x2, determinant, realPart, imaginaryPart;
cout << "Hello!!\n" ;
cout << "Here we will calculate the quadratic function ax^2 + bx + c = 0 \n";
cout << "Please insert the coefficients for a, b and c: \n ";
cout<<"\n Enter the first term of a:";
cin>>a;
cout<<"\n Enter the second term of b:";
cin>>b;
cout<<"\n Enter the third term of c:";
cin>> c;
determinant = b*b - 4*a*c;
if (determinant > 0) {
x1 = (-b + sqrt(determinant)) / (2*a);
x2 = (-b - sqrt(determinant)) / (2*a);
cout << "Roots are real and different." << endl;
cout << "x1 = " << x1 << endl;
cout << "x2 = " << x2 << endl;
}
else if (determinant == 0) {
cout << "Roots are real and same." << endl;
x1 = (-b + sqrt(determinant)) / (2*a);

cout << "x1 = x2 =" << x1 << endl;


}
else {
realPart = -b/(2*a);
imaginaryPart =sqrt(-determinant)/(2*a);
cout << "Roots are complex and different." << endl;
cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;
}
system ("pause")
;return 0;
}

OUTPUT WILL BE

AFTER ENTER THE COEFFICIENT A, B & C

You might also like