43.4k views
4 votes
Study the code segment below to see what it will output. Values of x and y will be displayed multiple times during the running of the program, and you might recognize a pattern. From the list of possible outputs listed two (2) are IMPOSSIBLE. Choose the two (2) outputs that are impossible for this code to produce.

1 Answer

2 votes

Values of x and y will be displayed multiple times during the running of the program, and you might recognize a pattern.

The outputs that are impossible for this code to produce are :

  • 0,0
  • 2,4

Explanation :

The code can take in any outputs, but it will be impossible for this code to produce 0,0 and 2,4

x <- 0

REPEAT_UNTIL( x = 3 ){

y <- 0

x <- x+1

REPEAT_UNTIL ( y = 3 ){

y <- y+1

DISPLAY( x + ", " + y)

}

}

There will be an output when you input

  • 1,1
  • 2,1
  • 2,2
User Ragesh
by
5.6k points