This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
An if-statement, and also all others like for, while etc, require a statement. Now "int b = 10;" is not a statement, it's a declaration. Using braces will work: it wraps all code inside the braces into one larger compound statement. And compound statements can have declarations.