Question

can any one please help me with this c++ code ASAP

media%2F018%2F018c81ca-ffdf-4aef-8120-62

media%2F9cf%2F9cf6cd4a-97d0-4cdc-ab27-a2

can any one please help me with this c++ code ASAP

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<cmath>
using namespace std;
int main() {
double a,b,c,disc,root1,root2,real,imag;
cout<<"This program calculates the root of a\n";
cout<<"      quadratic equation of the form\n";
cout<<"       ax + bx + c = 0\n\n";
cout<<"Please enter values of a,b and c: ";
cin>>a>>b>>c;
if(a==0 && b==0)
cout<<"The equation is degenerate and had no roots.\n";
else if(a==0)
cout<<"The equation has single root x = "<<-c/b<<endl;
else
{
disc=pow(b,2.0) -4*a*c;
if(disc>0.0)
{
disc=sqrt(disc);
root1=(-b + disc)/(2*a);
root2=(-b - disc)/(2*a);
cout<<"The two real roots are"<<root1<<"and"<<root2<<endl;
}
else if(disc<0.0) {
real = -b/(2*a);
imag =sqrt(-disc)/(2*a);
cout << "Both roots are imaginary.The 2 roots are " << endl;
cout << real << "+" << imag << "i" << endl;
cout <<real << "-" << imag << "i" << endl;
}
else
cout<<"Both roots are equal to "<<-b /(2*a)<<endl;
}
return 0;
}

Result... compiled and executed in 6.982 sec(s) This program calculates the root of a quadratic equation of the form ax +bxC-0 Please enter values of a,b and c: 2 3 4 Both roots are imaginary.The 2 roots are -0.75+1.19896i -0.75-1.19896i

Add a comment
Know the answer?
Add Answer to:
can any one please help me with this c++ code ASAP
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • i need this in C# please can any one help me out and write the full...

    i need this in C# please can any one help me out and write the full code start from using system till end i am confused and C# is getting me hard.I saw codes from old posts in Chegg but i need the ful complete code please thanks. Module 4 Programming Assignment – OO Design and implementation (50 points) Our Battleship game needs to store a set of ships. Create a new class called Ships. Ships should have the following...

  • SQL: Can someone please help me ASAP?? I need to create QUERIES for 2 INNER JOINS...

    SQL: Can someone please help me ASAP?? I need to create QUERIES for 2 INNER JOINS with 3 or more tables. I have an HR Database with the tables Region, Location, Country, Job, Department, Employee, Dependent. Any help would be greatly appreciated...

  • can someone please help me with the question “c” asap with an explanation please. 2. A...

    can someone please help me with the question “c” asap with an explanation please. 2. A lethal recessive condition is responsible for the death of 1 out of every 10,000 babies born in the United States. p2+2pq 1) P of dominantallele contaol led by a of ecessive allele,J par aldes a. Assuming HWE, what is the frequency 8f homowgo individuals in the population? 2 10.0001 10,000 b. Assuming HWE, what is the frequency of the recessive allele in the population?...

  • Is any one can help me to write the code? Please. 2. The binary file dates.bin...

    Is any one can help me to write the code? Please. 2. The binary file dates.bin is shown in a hexadecimal editor: DXV132 - dates.bin File Edit earch Address Bookmarks Tools VIscript Help 7000000303530|353134 30333233 31 33 0 5 0 5 1 4 0 323 1 3 ▲ 10 30 31 32 35 31 34 30 38 31 36 31 32 30 37 33 3101 2 5 1 4 0 8 1 6 1 20731 20 31 34 30 32...

  • Can someone please help me answer this question ASAP?? What is the product of the following...

    Can someone please help me answer this question ASAP?? What is the product of the following reaction? "ОН с. H20 он І. он IV. П. ОН ca ф ОН Ш. ІІ ООООО Ш IV у

  • ]\ Please can some help me with this one, snip the code and the sketch from...

    ]\ Please can some help me with this one, snip the code and the sketch from MATLAB  and post it here thanks Consider a causal LTI system described by y[n]-a y[n H = x[n] For o / and u 2 Use MATLAB to sketch the magnitude spectrum over 0 < w < 2n Consider a causal LTI system described by y[n]-a y[n H = x[n] For o / and u 2 Use MATLAB to sketch the magnitude spectrum over 0

  • can any one please help with this

    can any one please help with this

  • please help me asap 1 Determine the output for the following code: #include<stdio.h> int main static...

    please help me asap 1 Determine the output for the following code: #include<stdio.h> int main static int num; fornum : ++ num: num++) -- printf("%d". num): if num ==8) break; [10] COI retum 1 b) #include<stdio.h> int main int test: fortest - 0: tests=5: test); printer test: retum

  • Anyone can help me for these question please with typing around 250 words, need is asap!!!...

    Anyone can help me for these question please with typing around 250 words, need is asap!!! What did you learn in this class? (computer applications:Word, Excel & PPT ) Let's discuss what you learned in this class, what surprised you? Which of the 3 programs we learned make a difference and a great impact on you?

  • Can any one please help me. And also explain me step by step . (6 pts)...

    Can any one please help me. And also explain me step by step . (6 pts) Suppose that usernames w 0 and 2 digits, and must end with the special character #. usernames, but 34# and SMITH4# a routine for verifying that must start with between 1 and 3 letters, followed by between Thus CA34 and RRS# are valid newly proposed usernames meet the requirements. Formally define ccepts the set of strings that are acceptable usernames. You must ne each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT