Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. The quadratic formula is used to find the roots of quadratic equations of the

ID: 3726643 • Letter: #

Question

. The quadratic formula is used to find the roots of quadratic equations of the form ar' + br + c=0, (read that as-b+vo-or-b- 2 The formula itself is (read that as-b + or-u- 2a . 2a true. Write a function named quadraticSolution( that accepts three integer arguments corresponding to the variables a, b, and c, and displays the solutions. Just the function is fine, and since I know you're limited on time you don't have to worry about the include or using statements or a main() function as you would with a full program. You also don't have to account for imaginant

Explanation / Answer


#include <iostream>
#include<math.h>
using namespace std;
void quadraticSolution(int a,int b,int c){
double x1,x2;
int k = (b*b)-(4*a*c);
if(k<0){
cout<<"Roots are imaginary ."<<endl;
}else{
x1= (-b+sqrt(k))/(2*a);
x2= (-b-sqrt(k))/(2*a);
cout<<"Values of x are "<<x1<<" and "<<x2<<endl;
}
  
}
int main()
{
int a,b,c;
cout<<"Enter a , b and c : ";
cin>>a>>b>>c;
quadraticSolution(a,b,c);

return 0;
}