Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following code examples, where all variables are of type int: Example 1 x = n; y = x; while (x > 0) {

Consider the following code examples, where all variables are of type int:

Example 1

x = n;

y = x;

while (x > 0) {

y += 1; x /= 2;

}

Example 2

x = n;

y = x;

if (x > 0) {

while (x > 1) {

y += 1; x /= 2;

}

}

Assume that the two examples start with the same value for variable n. For which value(s) of n do the two code examples compute the same value for variable y?

I. Any value less than zero

II. The value zero

III. Any value greater than zero

1) I only

2) II only

3) III only

4) I and II only

5) I, II, and III

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

Students also viewed these Databases questions

Question

What is the difference between employee development and training?

Answered: 1 week ago

Question

Which ethical behaviors do I want to improve the most?

Answered: 1 week ago