SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
1: //Eqn roots.cpp
2: //Computes the roots of a quadratic equation
3: //In case of complex roots, both roots are assigned a value of 0
4: //Author: Wilson
5: //Date: 02/05/2015
6: #include "iostream"
7: #include "cmath"
8: using namespace std;
9: int main()
10: {float a(1),b(0),c(0);
11: float Rt1(0),Rt2(0);
12: float R(0);
13: cout<<"Specify the parameters of the Quadratic Equation"<<endl;
14: cout<<"enter a:";
15: cin>>a;
16: cout<<"Enter b:";
17: cin>>b;
18: cout<<"Enter c;";
19: cin>>c;
20: R=(b*b-4*a*c);
21: Rt1=((R>=0&&a!=0)?(-b+sqrt(R))/(2*a):0);
22: Rt2=((R>=0&&a!=0)?(-b-sqrt(R))/(2*a):0);
23: cout<<"nThe roots of the equation are a"<<Rt1<<" and "<<Rt2<<endl;
24: return 0;
25: }

Weitere ähnliche Inhalte

Was ist angesagt?

Web 2 . .3 Development Services
Web 2 . .3 Development ServicesWeb 2 . .3 Development Services
Web 2 . .3 Development ServicesTheawaster485
 
Computer network (6)
Computer network (6)Computer network (6)
Computer network (6)NYversity
 
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...DevDay.org
 
C言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunkC言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunkikegami__
 
Exercice.docx
Exercice.docxExercice.docx
Exercice.docximane26
 
サーバーレスアーキテクチャAzureFunctions概要
サーバーレスアーキテクチャAzureFunctions概要サーバーレスアーキテクチャAzureFunctions概要
サーバーレスアーキテクチャAzureFunctions概要Tsukasa Kato
 
OSC2007-niigata - mashup
OSC2007-niigata - mashupOSC2007-niigata - mashup
OSC2007-niigata - mashupYuichiro MASUI
 
C-- Sample Programs and Screenshots
C-- Sample Programs and ScreenshotsC-- Sample Programs and Screenshots
C-- Sample Programs and ScreenshotsBen Egadah
 
Kubernetes で実現するインフラ自動構築パイプライン
Kubernetes で実現するインフラ自動構築パイプラインKubernetes で実現するインフラ自動構築パイプライン
Kubernetes で実現するインフラ自動構築パイプラインYusuke Nojima
 
Web 2 . 0 .0 Programming Companies
Web 2 . 0 .0 Programming CompaniesWeb 2 . 0 .0 Programming Companies
Web 2 . 0 .0 Programming Companiesebooker97
 
RxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowRxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowViliam Elischer
 
Web 2 . 0 .Zero Coding Services
Web 2 . 0 .Zero Coding ServicesWeb 2 . 0 .Zero Coding Services
Web 2 . 0 .Zero Coding ServicesTheawaster485
 

Was ist angesagt? (19)

Web 2 . .3 Development Services
Web 2 . .3 Development ServicesWeb 2 . .3 Development Services
Web 2 . .3 Development Services
 
Computer network (6)
Computer network (6)Computer network (6)
Computer network (6)
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
8.2
8.28.2
8.2
 
Arrays
ArraysArrays
Arrays
 
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...
[DevDay2018] How does JavaScript actually work? - By: Vi Nguyen, Senior Softw...
 
C言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunkC言語静的解析ツールと Ruby 1.9 trunk
C言語静的解析ツールと Ruby 1.9 trunk
 
Exercice.docx
Exercice.docxExercice.docx
Exercice.docx
 
サーバーレスアーキテクチャAzureFunctions概要
サーバーレスアーキテクチャAzureFunctions概要サーバーレスアーキテクチャAzureFunctions概要
サーバーレスアーキテクチャAzureFunctions概要
 
OSC2007-niigata - mashup
OSC2007-niigata - mashupOSC2007-niigata - mashup
OSC2007-niigata - mashup
 
C-- Sample Programs and Screenshots
C-- Sample Programs and ScreenshotsC-- Sample Programs and Screenshots
C-- Sample Programs and Screenshots
 
Kubernetes で実現するインフラ自動構築パイプライン
Kubernetes で実現するインフラ自動構築パイプラインKubernetes で実現するインフラ自動構築パイプライン
Kubernetes で実現するインフラ自動構築パイプライン
 
Web 2 . 0 .0 Programming Companies
Web 2 . 0 .0 Programming CompaniesWeb 2 . 0 .0 Programming Companies
Web 2 . 0 .0 Programming Companies
 
Lab loop
Lab loopLab loop
Lab loop
 
C++
C++C++
C++
 
Using zone.js
Using zone.jsUsing zone.js
Using zone.js
 
Protecting C++
Protecting C++Protecting C++
Protecting C++
 
RxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowRxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrow
 
Web 2 . 0 .Zero Coding Services
Web 2 . 0 .Zero Coding ServicesWeb 2 . 0 .Zero Coding Services
Web 2 . 0 .Zero Coding Services
 

Andere mochten auch

Quadratic Equations
Quadratic EquationsQuadratic Equations
Quadratic EquationsLily Maryati
 
Module 10 linear inqualities PMR
Module 10 linear inqualities PMRModule 10 linear inqualities PMR
Module 10 linear inqualities PMRroszelan
 
Construction Of A Triangle
Construction Of A TriangleConstruction Of A Triangle
Construction Of A TriangleDulce Garza
 
Operations with Algebraic Fractions
Operations with Algebraic FractionsOperations with Algebraic Fractions
Operations with Algebraic FractionsKristen T
 
Algebraic fractions 4
Algebraic fractions 4Algebraic fractions 4
Algebraic fractions 4shaminakhan
 
Quadraticequation
QuadraticequationQuadraticequation
Quadraticequationsuefee
 
31 algebraic fractions (1)
31 algebraic fractions (1)31 algebraic fractions (1)
31 algebraic fractions (1)apecoraro
 
Lecture 08 quadratic formula and nature of roots
Lecture 08 quadratic formula and nature of rootsLecture 08 quadratic formula and nature of roots
Lecture 08 quadratic formula and nature of rootsHazel Joy Chong
 
Cones and frustum slides
Cones and frustum slidesCones and frustum slides
Cones and frustum slidesgjj97
 
Pyramid and frustum adds (area) (1)
Pyramid and frustum adds (area) (1)Pyramid and frustum adds (area) (1)
Pyramid and frustum adds (area) (1)Alfred Loh
 
Solving quadratic equations
Solving quadratic equationsSolving quadratic equations
Solving quadratic equationssrobbins4
 
Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Nathan Dennis
 
Plane Mensuration Perimeter of Polygons
Plane Mensuration Perimeter of PolygonsPlane Mensuration Perimeter of Polygons
Plane Mensuration Perimeter of PolygonsFarhana Shaheen
 
nature of the roots and discriminant
nature of the roots and discriminantnature of the roots and discriminant
nature of the roots and discriminantmaricel mas
 
Basic Mensuration
Basic MensurationBasic Mensuration
Basic MensurationKaran Bora
 
Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4hermiraguilar
 

Andere mochten auch (20)

Quadratic Equations
Quadratic EquationsQuadratic Equations
Quadratic Equations
 
Module 10 linear inqualities PMR
Module 10 linear inqualities PMRModule 10 linear inqualities PMR
Module 10 linear inqualities PMR
 
Construction Of A Triangle
Construction Of A TriangleConstruction Of A Triangle
Construction Of A Triangle
 
Operations with Algebraic Fractions
Operations with Algebraic FractionsOperations with Algebraic Fractions
Operations with Algebraic Fractions
 
Algebraic fractions 4
Algebraic fractions 4Algebraic fractions 4
Algebraic fractions 4
 
Quadraticequation
QuadraticequationQuadraticequation
Quadraticequation
 
Algebraic fractions
Algebraic fractionsAlgebraic fractions
Algebraic fractions
 
Simplifying & solving algebraic fractions
Simplifying & solving algebraic fractionsSimplifying & solving algebraic fractions
Simplifying & solving algebraic fractions
 
31 algebraic fractions (1)
31 algebraic fractions (1)31 algebraic fractions (1)
31 algebraic fractions (1)
 
Lecture 08 quadratic formula and nature of roots
Lecture 08 quadratic formula and nature of rootsLecture 08 quadratic formula and nature of roots
Lecture 08 quadratic formula and nature of roots
 
Cones and frustum slides
Cones and frustum slidesCones and frustum slides
Cones and frustum slides
 
Pyramid and frustum adds (area) (1)
Pyramid and frustum adds (area) (1)Pyramid and frustum adds (area) (1)
Pyramid and frustum adds (area) (1)
 
Solving quadratic equations
Solving quadratic equationsSolving quadratic equations
Solving quadratic equations
 
ppt on frustum.
 ppt on frustum. ppt on frustum.
ppt on frustum.
 
Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1
 
Plane Mensuration Perimeter of Polygons
Plane Mensuration Perimeter of PolygonsPlane Mensuration Perimeter of Polygons
Plane Mensuration Perimeter of Polygons
 
nature of the roots and discriminant
nature of the roots and discriminantnature of the roots and discriminant
nature of the roots and discriminant
 
Basic Mensuration
Basic MensurationBasic Mensuration
Basic Mensuration
 
Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4
 
Fractions
FractionsFractions
Fractions
 

Kürzlich hochgeladen

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 

Kürzlich hochgeladen (20)

Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 

Roots of a quadratic equation1

  • 1. 1: //Eqn roots.cpp 2: //Computes the roots of a quadratic equation 3: //In case of complex roots, both roots are assigned a value of 0 4: //Author: Wilson 5: //Date: 02/05/2015 6: #include "iostream" 7: #include "cmath" 8: using namespace std; 9: int main() 10: {float a(1),b(0),c(0); 11: float Rt1(0),Rt2(0); 12: float R(0); 13: cout<<"Specify the parameters of the Quadratic Equation"<<endl; 14: cout<<"enter a:"; 15: cin>>a; 16: cout<<"Enter b:"; 17: cin>>b; 18: cout<<"Enter c;"; 19: cin>>c; 20: R=(b*b-4*a*c); 21: Rt1=((R>=0&&a!=0)?(-b+sqrt(R))/(2*a):0); 22: Rt2=((R>=0&&a!=0)?(-b-sqrt(R))/(2*a):0); 23: cout<<"nThe roots of the equation are a"<<Rt1<<" and "<<Rt2<<endl; 24: return 0; 25: }