Having trouble

This is my code

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main ()
{
//declare variables
double x; //number input by user

cout<< "Please enter a number to use as x"<<endl;
cin>> x;

cout<< "x= " << x << endl;

double y; //number solving for

if ((-3<=x) && (x<=2))
{
y=(x*x)+(2*x)-3;
}
else if ((2<x) && (x<=10))
{
y=(5*x)+7;
}
else if (x<-3)//first part of third parameter
{
y=0;
}
else if (x>10)//second part of third parameter
{
y=0;
}

cout << "y= "<< y ;
cout<< setprecision(3) << y <<endl;

return 0;
}

I am trying to find y. For some reason when entering an X that is <-3 or >10 it does not give me 0 like I would like it to. could anyone help?
I tried your program. I entered -4 and 11 and got 0 both times.
I don't see your problem.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
Idk why i just can't get it to output 0 on mine. I will try to remember to use the Tags. thank you!
Topic archived. No new replies allowed.