GateAI
Parsing

GATE CSE 2016 Set 1 · Q45

NAT2 marksEasy

Time

The attributes of three arithmetic operators in some programming language are given below. The value of the expression 2−5+1−7∗32 - 5 + 1 - 7 * 3 in this language is _______.

GATE CSE 2016 Set 1 Q45 diagram

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 9 (±0)

Parsing

From the given operator attribute table:

  • +: Precedence = High, Associativity = Left

  • -: Precedence = Medium, Associativity = Right

  • *: Precedence = Low, Associativity = Left

Expression to evaluate: 2 - 5 + 1 - 7 * 3

  1. Step 1: The operator + has the highest precedence.

    • Evaluate 5 + 1 = 66.

    • Expression becomes: 2 - 6 - 7 * 3

  2. Step 2: The operator - has the next highest precedence (Medium) and is Right-associative.

    • In 2 - 6 - 7, we group from the right: 2 - (6 - 7).

    • Evaluate inner expression 6 - 7 = −1-1.

    • Evaluate 2 - (-1) = 33.

    • Expression becomes: 3 * 3

  3. Step 3: The operator * has the lowest precedence (Low).

    • Evaluate 3 * 3 = 99.

Thus, the value of the expression is 9.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Parsing previous year question is Q45 of the GATE CSE 2016 Set 1 paper. Find more GATE CSE PYQs on Parsing in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Parsing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Parsing in GATE CSE

Parsing has 23 GATE CSE PYQs across 16 papers from 2012 to 2026. 3 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2016 Set 1.

How GATE tests Parsing

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q45 · NAT

The attributes of three arithmetic operators in some programming language are given below. The value of the expression 2 - 5 + 1 - 7 * 3 in this language is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.