I'm having trouble with syntax errors before "else" when I compile

My code looks like this:

if (x == 1)
{
        statement1
        else if (x == 2)
                     statement2
        else if (x == 3)
                     statement3
}
else
       statement4

It gives me the errors on the middle else's. I know its something small but I can't seem to figure it out. If I try to add more braces inside the else if I start to lose my variable definitions.

If x is 1, it won't be 2 or 3.

if (x == 1)
{
        statement1
}
else if (x == 2)
{
        statement2
}
else if (x == 3)
{
        statement3
}
else
{
       statement4
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.