Writing Arithmetic Expressions - Visual Basic Questions and Answers

1.

An arithmetic expression contains one or more __________

   A.) Arithmetic operators
   B.) Short-hand operators
   C.) Relational operators
   D.) Logical operators

Answer: Option 'A'

Arithmetic operators

Most application requires the computer to perform at least one calculation. You instruct the computer to perform calculations by writing arithmetic expression, which is an expression that contains arithmetic operators.

DigitalOcean Referral Badge

2.

The __________ numbers indicate the order in which the computer performs the operation in an expression.

   A.) Precedence
   B.) Binary
   C.) Ternary
   D.) Associativity

Answer: Option 'A'

Precedence

The precedence numbers indicate the order in which the computer performs the operation in an expression. Operators with precedence number 1 are performed before operations with precedence number 2, and so on.

DigitalOcean Referral Badge

3.

You can use __________ to override the order of precedence.

   A.) Curly braces
   B.) Parenthesis
   C.) Associativity
   D.) Third bracket

Answer: Option 'B'

Parenthesis

You can use parenthesis to override the precedence, because operators within parenthesis are always performed before operators outside parenthesis.

DigitalOcean Referral Badge

4.

__________ and __________ operators use same symbol.

   A.) Addition, subtraction
   B.) Addition, multiplication
   C.) Multiplication, Division
   D.) Subtraction, negation

Answer: Option 'D'

Subtraction, negation

Subtraction and negation use the same symbol that is hyphen (-), but there is a difference between both operators; since subtraction is binary operator and negation is unary operator.

DigitalOcean Referral Badge

5.

Unary and Binary refer to the number of __________ needed by the operator.

   A.) Operation
   B.) Operand
   C.) Operator
   D.) Expression

Answer: Option 'B'

Operand

Unary and binary refers to the number of operands required by the operator. Unary requires single operand. Example of such is negation, such as -10, 12, -a, -b, etc. binary requires two operands. Example of such is addition, subtraction, multiplication, division, such as a+b, a-b, a*b, a/b etc.

DigitalOcean Referral Badge

6.

When an expression contains more than one operator with same priority, then they are evaluated according their __________

   A.) Precedence
   B.) Associativity
   C.) Binary
   D.) Unary

Answer: Option 'B'

When an expression contains more than one operator with same priority, then they are evaluated according to their associativity. Associativity tells whether evaluation should be done from left to right or right to left for same priority operators. As we know, = and – have same priority, and both of their associativity is from left to right, thus an expression containing both + and – is evaluated from left to right.

DigitalOcean Referral Badge

7.

The __________ operator is used to divide two integers.

   A.) Addition
   B.) Modulus
   C.) Subtraction
   D.) Integer division

Answer: Option 'D'

The integer division operator divides two integers and returns the result as an integer. For example 211\4 results into 52 whereas if you use the standard division operator then 211/4 results into 52.75 rather than 52.

DigitalOcean Referral Badge

8.

The __________ operator is commonly used to determine whether a number is even or odd.

   A.) Integer division
   B.) Subtraction
   C.) Modulus
   D.) Addition

Answer: Option 'C'

Modulus

The modulus operator is commonly used to determine whether a number is even or odd. If you divide a number by 2 and the remainder is 0, the number is even, and if the remainder is 1, the number is odd. Thus the result of any number mod 2 determines whether the number is even or odd.

DigitalOcean Referral Badge

9.

To include a percentage in arithmetic operators we use __________

   A.) We cannot use percentage
   B.) Percentage symbol
   C.) Decimal equivalent
   D.) Division

Answer: Option 'C'

Decimal equivalent

Arithmetic operators do not entertain comma or special characters, such as dollar sign or percentage. Thus to introduce the concept of percentage in an arithmetic expression we use its decimal equivalent instead of symbol such as 5%.

DigitalOcean Referral Badge

10.

The __________ operator returns the remainder of the division.

   A.) Addition
   B.) Modulus
   C.) Integer division
   D.)

Subtraction

Answer: Option 'B'

Modulus

The modulus operator is also used to divide two numbers, but the numbers need not have to be integers. After dividing the numbers the modulus operation returns the remainder of the division. For example, 211 mod 4 returns 3, which is the remainder after dividing 211 by 4.

DigitalOcean Referral Badge

Writing Arithmetic Expressions - Visual Basic Questions and Answers Download Pdf

Recent Posts