190k views
5 votes
What will be the output of the following code snippet? token = False while token : print("Hello")

A) "Hello" will continue to be displayed until the user stops the program.
B) No output because of compilation error.
C) No output after successful compilation.
D) "Hello" will be displayed only once.

User DEHAAS
by
5.3k points

1 Answer

3 votes

Answer:

Hi!

The correct answer is B.

Step-by-step explanation:

The code snippet doesn't follow the correct form of writing a while loop, so it will crash when compiles.

One correct form to write the code is:

token = false;

while (token){ // Evaluate token, if true prints else terminates the loop. In this case, token is false so, no output and finish the program.

print("Hello");

};

User Obby
by
4.9k points