Essentials
Accenture PrimermediumEssentialsSoftware Fundamentals

Choose the correct pseudocode for the below problem statement. Problem Statement : Find Maximum value Choose a pseudo code to find the maximum values in each row of a matrix. Assume it is a 3x3 matrix. Explanation : Matrix will be with index (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2) Assume the values for this matrix are 12 23 18 45 32 60 42 39 23 The output will be Max value in row 1 is 23 Max value in row 2 is 60 Max value in row 3 is 42

Answer options

A
BEGIN DECLARE variable arr[3][3] FOR i IN 0 to 2 DO FOR j IN 0 to 2 DO READ arr[i][j] END FOR END FOR FOR i IN 0 TO 2 DO SET max = arr[i][0] FOR j IN 0 TO 2 DO IF arr[i][j]>max THEN max = arr[i][j] END IF END FOR PRINT "Max value in row "+(i+1)+" is "+max END FOR END
B
Incorrect pseudocode with wrong initialization/order
C
Incorrect pseudocode with missing loop or condition
D
Incorrect pseudocode with wrong output statement

Correct answer: BEGIN DECLARE variable arr[3][3] FOR i IN 0 to 2 DO FOR j IN 0 to 2 DO READ arr[i][j] END FOR END FOR FOR i IN 0 TO 2 DO SET max = arr[i][0] FOR j IN 0 TO 2 DO IF arr[i][j]>max THEN max = arr[i][j] END IF END FOR PRINT "Max value in row "+(i+1)+" is "+max END FOR END

Explanation

The correct answer is: BEGIN DECLARE variable arr[3][3] FOR i IN 0 to 2 DO FOR j IN 0 to 2 DO READ arr[i][j] E....

Related Accenture Essentials questions

Practice more Accenture Essentials questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.