Click here to Skip to main content
15,392,399 members
Articles / Programming Languages / C++
Alternative
Tip/Trick
Posted 26 Oct 2010

Tagged as

Stats

7.5K views
2 bookmarked

A simple program to solve quadratic equations with

Rate me:
Please Sign up or sign in to vote.
1.50/5 (4 votes)
7 Nov 2010CPOL
#include<stdio...
C++
#include<stdio.h>
#include<conio.h>
void main()
{
   float a,b,c,x1,x2;
   clrscr();
   printf("Enter a=");
   scanf("%f",&a);
   printf("Enter b=");
   scanf("%f",&b);
   printf("Enter b=");
   scanf("%f",&b);
   x1=(-(b)+(sqrt((b^2)-(4*a*c))))/(2*a)
   x2=(-(b)-(sqrt((b^2)-(4*a*c))))/(2*a)
   printf("x=%f",x1);
   printf("\n or \n x=%f",x2);
   getch();
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

TomSeaton
United States United States
No Biography provided

Comments and Discussions

 
GeneralReason for my vote of 1 completely incorrect code Pin
Phil J Pearson16-Nov-10 10:13
MemberPhil J Pearson16-Nov-10 10:13 
GeneralReason for my vote of 2 Poor error handling. Pin
BillW3311-Nov-10 3:20
professionalBillW3311-Nov-10 3:20 
GeneralReason for my vote of 1 Many problems esp. that ^ is not pow... Pin
Andrew Phillips7-Nov-10 15:16
MemberAndrew Phillips7-Nov-10 15:16 
Reason for my vote of 1
Many problems esp. that ^ is not power operator.
GeneralReason for my vote of 2 2 For the effort, but Tom, that code... Pin
Harrison H26-Oct-10 9:42
MemberHarrison H26-Oct-10 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.