Before attending this lab, you should have read and be familiar with Chapter 3 s
ID: 3585609 • Letter: B
Question
Before attending this lab, you should have read and be familiar with Chapter 3 sections 3.1, 3.2, and 3.3 of Delores Etter's Engineering Problem Solving with C Answer the questions below in a typed document, numbered appropriately. Print out this sheet as a cover page. Bring the completed assignment to your next lab class. 1) 2) 3) Write a conditional expression that returns a value of true if the absolute values of the variables “A" and "B" are both less than 0.0001. Write a conditional expression that returns a value of true if the absolute value of "A" is less than 0.0001, but the absolute value of "B" is greater than that threshold. Write a conditional expression that returns a value of true if the quantity B2-4AC is less than zero 4) Write an if/else statement that prints an error message in the case where the condition from 1) s true Write an assignment statement that calculates the result of the quadratic equation and puts one of the two possible solutions in a variable called x1 5) 6) B'-4AC is known as the discriminant of the quadratic equation. Assuming that the discriminant is negative, write an expression in terms of A, B, and C that describes the complex solutions of the quadratic equation. This expression should be in the form of: x=( real part) ± i"(imaginary part)Explanation / Answer
Ans1.
#include<iostream>
#include<cmath>
using namespace std;
main()
{
float A,B;
cout<<"enter the value";
cin>>A>>B;
(A<0.0001&&B<0.0001)?cout<<"True":cout<<"false";
}
Ans2.
#include<iostream>
#include<cmath>
using namespace std;
main()
{
float A,B;
cout<<"enter the value";
cin>>A>>B;
(A<0.0001&&B>0.0001)?cout<<"True":cout<<"false";
}
Ans3
#include<iostream>
#include<cmath>
using namespace std;
main()
{
int A,B,C,D;
cout<<"enter the value";
cin>>A>>B>>C;
D=(B*B)-(4*A*C);
(D<0)?cout<<"True":cout<<"False";
}
Ans4.
#include<iostream>
#include<cmath>
using namespace std;
main()
{
float A,B;
cout<<"enter the value";
cin>>A>>B;
if(A<0.0001&&B<0.0001)
cout<<"True";
else
cout<<"False";
}
Ans5.
#include<iostream>
#include<cmath>
using namespace std;
main()
{
float A,B,C,D,x1,x2,D1;
cout<<"enter the value";
cin>>A>>B>>C;
D=(B*B)-(4*A*C);
if(D<0)
{
cout<<"roots are imaginary";
}
else
{
cout<<"Roots are real and these are:";
D1=sqrt(D);
x1=(-B+D1)/2*A;
x2=(-B-D1)/2*A;
cout<<"Root X1="<<x1<<" ";
cout<<"Root X2="<<x2<<" ";
}
}
Ans6.
#include<iostream>
#include<cmath>
using namespace std;
main()
{
float A,B,C,D,x1,x2,D1,real,imag;
cout<<"enter the value";
cin>>A>>B>>C;
D=(B*B)-(4*A*C);
D1=sqrt(D);
real=-B/2*A;
cout<<"Root X1="<<real<<"+i"<<D1<<" ";
cout<<"Root X2="<<real<<"-i"<<D1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.