Question
What is the output of the following pseudo-code? ``` count = 0 for i from 1 to 3: for j from 1 to i: count = count + 1 print(count) ```
Solution
Dry Run: `count = 0` `i = 1`: `j = 1`: `count = 0 + 1 = 1` `i = 2`: `j = 1`: `count = 1 + 1 = 2` `j = 2`: `count = 2 + 1 = 3` `i = 3`: `j = 1`: `count = 3 + 1 = 4` `j = 2`: `count = 4 + 1 = 5` `j = 3`: `count = 5 + 1 = 6` Final `count = 6`
More IT DBMS Questions
- Which debugging tool allows a developer to pause program execution at specific lines, inspect variable values, and execute code step-by-step?
- What is 'query optimization' in DBMS?
- What is a primary key in a relational database?
- Which of the following commands are used to put a restriction on the number of rows returned from a query?
- Examine the following Java-like code: ```java class Parent { String name = "Parent"; public void display() { Syst...
- What is a table joined with itself called?
- Consider a scenario in an OOP application where a `NullPointerException` (or equivalent) occurs when trying to access a member of an object. What is the mo...
- What is the purpose of 'indexing' in a database?
- A PL/SQL `TRIGGER` is a stored program that automatically executes in response to:
- Which concurrency anomaly is specific to phantom reads?