Data Structures & AlgorithmsHardTCS NQT · Infosys
Evaluate the integer expression 2 - 3 * 4 + 10 / 3 using standard precedence and integer division that truncates toward zero. What is the result?
- A. -6
- B. -7
- C. -9
- D. 5
Correct answer: B. -7
Multiplication and division come before addition and subtraction, and 10 / 3 truncates to 3. Evaluating left to right gives a different result.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the length of the longest run of consecutive integers (in any order) present in the array [9, 1, 4, 7, 3, -1, 0, 5, 8, -1, 6]?
- How many index pairs i < j in the array [1, 5, 3, 4, 2, 7, 9] have absolute difference exactly 2?
- In the array [1, 5, 5, 5, 5, 5, 5, 5, 5, 9], how many distinct value pairs {x, y} with x <= y satisfy x + y = 10, where x and y both occur…
- What is the length of the longest substring of aabccbb that can be made into a string of one repeated letter by replacing at most 2…
- How many substrings of abcabc contain all of the three letters a, b and c at least once?
- How many substrings of aabacbebebe contain exactly two distinct characters?