Multiplication operator with or without braces
The parentheses should definitely make no difference. My guess is that
what you saw was just a coincidence. The analog ranges you have defined
are extremely narrow. Any instability in the circuit can throw your
readings out of the expected ranges. If you get a reading that does not
fit in any of those ranges, none of the if conditions will evaluate to
true, and you end up with the result being zero, as this is how you
initialized the variable ans.

I suggest two changes to your program:


Make the ranges wider
Repeatedly read the analog input until you get a valid reading.


To illustrate the second item, here is a code snippet that splits the
logic of you if chain in two parts: first read the operator
(repeatedly until we get a valid reading), then perform the operation:

// Read the operator.
char op = ' ';  // space = no operator read so far
do {
    int val = analogRead(A0);
    if (val == 0) op = '+';
    if (val &gt;= 97 &amp;&amp; val &lt;= 98) op = '*';
    if (val &gt;= 253 &amp;&amp; val &lt;= 254) op = '/';
    if (val &gt;= 407 &amp;&amp; val &lt;= 408) op = '-';
} while (op == ' ');

// Perform the operation.
switch (op) {
    case '+': ans = num1 + num2; break;
    case '*': ans = num1 * num2; break;
    case '/': ans = num1 / num2; break;
    case '-': ans = num1 - num2; break;
}