Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is the error in this program?

0 votes
asked Feb 4, 2019 by fizzajaved (120 points)
#include<conio.h>

int main()

{

//*SOLVING QUARDRATIC EQUATION FOR "X"

int a,b,c,x1,x2,d;

    cout<<"enter coefficients a,b and c";

    cin>>a>>b>>c;

    d=b*b-4*a*c;

    if(d>0)

    {

        x1=(-b+sqrt(d))/(2*a);

        x2=(-b-sqrt(d))/(2*a);

        cout<<"two real solution."<<endl;

        cout<<"x1="<<x1<<endl;

        cout<<"x2="<<x2<<endl;

    }

    else if(d==0)

    {

        cout<<"one real solution."<<endl;

        x1=(-b+sqrt(d))/(2*a);

        cout<<"x1=x2"<<x1<<endl;

    }

    else

    cout<<"no real solutions."<<endl;

    getch();

    return 0;

}

5 Answers

0 votes
answered Feb 4, 2019 by khagesh jayaswal (140 points)
include <math.h> header file for sqrt function
0 votes
answered Feb 5, 2019 by COMPUTER Boy's (150 points)
#include<stdio.h>
0 votes
answered Feb 5, 2019 by Heram Gowri (140 points)

#include<stdio.h>

0 votes
answered Feb 5, 2019 by anonymous
#include<iostream.h> not included.
0 votes
answered Feb 5, 2019 by anonymous
#include<iostream>

#include<math.h>

using namespace std;

to write after including conio header file
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...