error else without a previous if

I cant seem to see my error here. relatively new to C++. Please help.

I am looking through my code and cannot find the error?

2 Answers 2

The else if needs a condition to evaluate. So something like else if(some condition) <. >.

If you’re looking to default after the first if fails, just use else <. >.

Also, you need curly braces around your if and else blocks, and at the end of main.

Your code has some syntax and logical errors. Like else if() have to given condition, income will be modified twice if you will not put parenthesis. I will suggest you to follow some tutorial for learning syntax of language.

modified code is below with changes described as comments .

using namespace std;

int main()
<
int value;

if ( value >0);
<
cout Лучший ответ

копируя к себе взял или неполный кусок кода или скопировал с пропушенным или лишним «;» — и оппаньки.
очередное «иначе» оказалось непривязанным ни к какому «если»

тут же не телепаты -не видим что ты пытаешься компилить из всего что там есть.

a iI d ihA yaM b cSVOs y FIYDT ZPhZ E DGGem l QbGZK a ausx s vM t NSMKB i k c fiB

Answer Wiki

You don’t say what language you’re using, but at a guess it’s one of the curly brace ones like Java or C#

The braces are missing after the if and before the else. You want to do more than one thing and need to tell the compiler to pull those statements together.

Often people have coding standards that say you should always put the braces in even when they aren’t needed so that you don’t get this kind of error.

Оцените статью