C++ problem with output

Hey! So I wrote this code:

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a,b,c;
double x1,x2,delta;
cin>>a;
cin>>b;
cin>>c;
delta=b*b-4*a*c;
x1=(-b+sqrt(delta))/(2*a);
x2=(-b-sqrt(delta))/(2*a);
cout<<"x1="<<x1<<"x2="<<x2;
}

For some reason it only outputs "nan". Any ideas why? I tried with many inputs.
If delta is negative, the roots are imaginary.
1
2
3
4
5
6
7
    if (delta < 0)
    {
        cout << "No real roots\n";
    }
    else
        // etc.
 
Thanks pal!
Topic archived. No new replies allowed.