### All Computer Science Resources

## Example Questions

### Example Question #1 : Evaluating Numerical Expressions

`int a = 49;`

`int b = 6;`

` `

`int c = 49 % 6;`

What is the value of `c`

?

**Possible Answers:**

**Correct answer:**

The modulus (or modulo) operator returns the remainder of a division statement. It only works with integer operands. Thus, it will only return an integer result. Six is able to divide forty-eight a maximum of eight times.

And then

Thus,

### Example Question #2 : Evaluating Numerical Expressions

`int a = 5;`

`a += 3.14;`

Using the language C++ or Java, what will the value of `a`

be after the above code snippet?

**Possible Answers:**

**Correct answer:**

When using the plus-equals (+=) operator, the answer is cast to the type of the left-hand argument. Since `a`

was an `int`

, the value returned by the expression is converted to `int`

before it is stored in `a`

. Thus, the decimal point and any information behind the decimal is truncated.

### Example Question #3 : Evaluating Numerical Expressions

Evaluate the mathematical equation?

**Possible Answers:**

**Correct answer:**

You have to remember PEMDAS.

Multiplication and Division take precedence first

(double multiplied by an int equal a double)

Addition and Subtraction after

Certified Tutor