Accenture Software Engineering Practice Question
Choose the correct pseudocode for the below problem statement. Problem Statement : Hide and Seek One day, Bunny and his friends were playing hide and seek in the forest. Tom went along to hide. He finds an abandoned bag containing a board(8x8) game in a cave. He gets excited and starts playing the game only to realizes that it's magical. He has three chances to roll the dice. Each turn's outcome will lead into a new surrounding and some would be dangerous. If the outcome of rolling dices is in multiples of 3 then he will be caught in a dangerous phase. Note if any one outcome is multiple of 3, then tom is in danger. (If the outcome of rolling dices is either 0 or less than that you should tell Tom as "Invalid Turn". ) Example : Enter value of turn 1 10 Enter value of turn 2 5 Enter value of turn 3 2 Tom is safe Example : Enter value of turn 1 12 Enter value of turn 2 5 Enter value of turn 3 2 Tom is in danger a. BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END b. BEGIN READ turn1, turn2, turn3 DECLARE variables turn1,turn2,turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END c. BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN ELSE PRINT "Tom is Safe" IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" END IF ELSE PRINT "Invalid turn" END IF END d. BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 PRINT "Tom is in Danger" IF turn1>0 AND turn2>0 AND turn3>0 THEN ELSE PRINT "Tom is Safe" IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN END IF ELSE PRINT "Invalid turn" END IF ENDAnswer options
A
He finds an abandoned bag containing a board(8x8) game in a cav
B
He gets excited and starts playing the game only to realizes that it's magical. He has three chances to roll the dic
C
Each turn's outcome will lead into a new surrounding and some would be dangerous. If the outcome of rolling dices is in multiples of 3 then he will be caught in a dangerous phas
D
Note if any one outcome is multiple of 3, then tom is in danger. (If the outcome of rolling dices is either 0 or less than that you should tell Tom as "Invalid Turn". ) Example : Enter value of turn 1 10 Enter value of turn 2 5 Enter value of turn 3 2 Tom is safe Example : Enter value of turn 1 12 Enter value of turn 2 5 Enter value of turn 3 2 Tom is in danger
E
BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END
F
BEGIN READ turn1, turn2, turn3 DECLARE variables turn1,turn2,turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END
G
BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN ELSE PRINT "Tom is Safe" IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" END IF ELSE PRINT "Invalid turn" END IF END
H
BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 PRINT "Tom is in Danger" IF turn1>0 AND turn2>0 AND turn3>0 THEN ELSE PRINT "Tom is Safe" IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN END IF ELSE PRINT "Invalid turn" END IF END
Correct answer: BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END
Explanation
Correct answer: BEGIN DECLARE variables turn1,turn2,turn3 READ turn1, turn2, turn3 IF turn1>0 AND turn2>0 AND turn3>0 THEN IF turn1%3==0 OR turn2%3==0 OR turn3%3==0 THEN PRINT "Tom is in Danger" ELSE PRINT "Tom is Safe" END IF ELSE PRINT "Invalid turn" END IF END.