Computers and Technology, 03.03.2020 05:57 lillieannereed
Write a program to solve a quadratic equation. The program should allow the user to enter the values for a, b, and c. If the discriminant is less than zero, a message should be displayed that the roots are imaginary; otherwise, the program should then proceed to calculate and display the two roots of the eqaution. (Note: Be certain to make use of the squareRoot () function that you developed in this chapter.) (In C language)
Hint: This should not be too hard. You need to get some numbers from the user, do some calculations, check if the discriminate is negative, then use the textbook author’s squareRoot function to finish up the calculations!
program 7.8:
// Function to calculate the absolute value of a number
#include
float absoluteValue(float x)
{
if (x < 0)
x = -x;
return (x);
}
// Function to compute the square root of a number
float squareRoot(float x)
{
const float espsilon = .00001;
float guess = 1.0;
while (absoluteValue(guess * guess - x) >= espsilon)
guess = (x / guess + guess) / 2.0;
return guess;
}
int main(void)
{
printf("squareRoot (2.0) = %f\n", squareRoot(2.0));
printf("squareRoot (144.0) = %f\n", squareRoot(144.0));
printf("SquareRoot (17.5) = %f\n", squareRoot(17.5));
return 0;
}
Answers: 2
Computers and Technology, 23.06.2019 01:30
1. which of the following is a search engine? a) mozilla firefox b)internet explorer c)google d)safari 2. which of the following statements is true? a) all search engines will provide the same results when you enter the same query. b) all search engines use the same amount of advertisements. c) some search engines are also browsers. d) search engines often provide different results, even when you enter the same query.
Answers: 2
Computers and Technology, 24.06.2019 07:20
Ingrid started speaking about her slide presentation. when she clicked to th"third slide, which had just a picture of an elephant, she forgot what she wassupposed to talk about. what could ingrid do to avoid this situation in thefuture? oa. print handouts for her audience.ob. add presenter's notes to each slide.oc. add a video to each slide.od. save her slide presentation to a flash drive
Answers: 2
Computers and Technology, 24.06.2019 07:30
Consider the folloeing website url: what does the "http: //" represent? a. protocal identifier. b. ftp. c. domain name d. resource name
Answers: 2
Computers and Technology, 24.06.2019 16:00
This isn't about school but every time it tells me to watch an ad to unlock the answer to a question it prompts a survey and it just keeps loading. so i haven't been able to get answers for my tests in like a week.
Answers: 2
Write a program to solve a quadratic equation. The program should allow the user to enter the values...
Biology, 26.04.2021 21:30
Physics, 26.04.2021 21:30
Mathematics, 26.04.2021 21:30
Spanish, 26.04.2021 21:30
Mathematics, 26.04.2021 21:30
Mathematics, 26.04.2021 21:30
Mathematics, 26.04.2021 21:30
Chemistry, 26.04.2021 21:30
History, 26.04.2021 21:30
Mathematics, 26.04.2021 21:30