Vyom World.com Let's Touch the Sky Together!
 Home VyomWorld.com Home Free Magazines! VyomLinks.com Home JobsAssist.com Home Vyom Network Contact Us Jobs & Careers Resume Submitter Placement Papers IT Companies Directory Computer Jobs Interview Questions Online Exams Vyom Career eMag. Fun Screensavers New! Send FREE SMS! SMS Jokes Source Codes Library Source Codes Home ASP Source Codes C Source Codes C++ Source Codes COBOL Source Codes Java Source Codes Pascal Source Codes Submit Source Codes GATE GATE an Overview GATE Preparation Study Materal GRE GRE an Overview GRE Questions GRE Preparation GRE Universities TOEFL Preparation TOEFL Resources GMAT Preparation GMAT Resources MBA Preparation MBA Resources Networking Concepts Networking Concepts Testing Preparation Testing Resources Webmasters Free Traffic Builder Webmaster Articles Web Hosting Tutorials Hardware Tutorial 1500 Free eBooks New! FREE Publications
Vyom Career eMag.
 Get 9,000+ Interview Questions & Answers in an eBook. 9,000+ Interview Questions All Questions Answered 5 FREE Bonuses Free Upgrades Get it now!
Get 9,000+ Interview Questions with Answers in an eBook

Home >> Source Codes Library Home >> Language Home >> Category Home > > Item Description
Search Code Library

 Title Program to Calculate roots of 4th order algebraic equation of the form ax^4 + bx^3 + cx^2 + dx + e = 0. Author: Adarsh Ramamurthy Visitor Submitted Source Code Author Email: adarsh83@rediffmail.com Description: Calculates all roots( both complex and real ) of a fourth order algebraic equation of the form ax^4 + bx^3 + cx^2 + dx + e = 0 and displays them. Employs OOPS. Hits: 5180 Since 25th November, 2003 Code: Select and Copy the Code #include #include #include #include #include const int IMAX = 800; class coeffs { public : float a, b, c, d, e, x, y, p, q, r, z; void getdata(void); void divide(void); void chkrealcmplx(void); void dispreal(float, float, float); void dispcomplx(float, float, float); }; void coeffs :: getdata() { cout<<"Enter coefficients 'a' through 'e' :\n\n"; cin>>a>>b>>c>>d>>e; } void coeffs :: divide(void) { int i; float y1,z1; b = b/a; c = c/a; d = d/a; e = e/a; a = 1; y = d/c; z = e/c; x = 1; for(i=1;i<=IMAX;i++) { y1 = (d-z*(b-y))/((c-z)-y*(b-y)); z1 = e/((c-z)-y*(b-y)); y = y1; z = z1; p = 1; q = b-y; r = (c-z)-y*(b-y); } } void coeffs :: chkrealcmplx(void) { float delta1,delta2; delta1 = q*q - 4*p*r; delta2 = y*y - 4*x*z; if(delta1<0) { cout<<"\nRoots R1 and R2 are complex\n"; cout<<"Roots are :\n\n"; dispcomplx(delta1,p,q); } if(delta2<0) { cout<<"\nRoots R3 and R4 are complex\n"; cout<<"Roots are :\n\n"; dispcomplx(delta2,x,y); } if(delta1>=0) { cout<<"\nRoots R1 and R2 are real\n"; cout<<"Roots are :\n\n"; dispreal(delta1,p,q); } if(delta2>=0) { cout<<"\nRoots R3 and R4 are real\n"; cout<<"Roots are :\n\n"; dispreal(delta2,x,y); } } void coeffs :: dispreal(float delta,float A,float B) { float r1,r2; r1 = (-B+sqrt(delta))/(2*A); r2 = (-B-sqrt(delta))/(2*A); cout<

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home