Software Engineering
Accenture PrimermediumSoftware Engineering05 Arrays

Accenture Software Engineering Practice Question

Select the appropriate code snippet for the given problem statement provided as pseudocode. Problem Statement : Dinner Plan Five friends plan to go out for dinner. They plan to order equal number of dishes. Each row specifies individual cost. Find the total amount each person needs to pay. Assume the values for this matrix for 3 dishes are 12 23 18 45 32 60 42 39 23 54 42 60 25 84 30 The output will be Amount to be paid by person 1 is 53 Amount to be paid by person 2 is 137 Amount to be paid by person 3 is 104 Amount to be paid by person 4 is 156 Amount to be paid by person 3 is 139 Explanation : Output is the sum of each row Code: BEGIN DECLARE variable arr[5][20], n, sum=0 ___________________ FOR j IN 0 to n-1 DO READ arr[i][j] END FOR END FOR FOR i IN 0 TO 4 DO SET sum = 0 FOR j IN 0 TO n-1 DO sum = sum + arr[i][j] END FOR PRINT "Amount to be paid by person "+(i+1)+" is "+sum END FOR END a. FOR i IN 0 to 5 DO b. FOR i IN 0 to n DO c. FOR i IN 0 to 4 DO d. FOR i IN 0 to 3 DO

Answer options

A
Problem Statement : Dinner Plan Five friends plan to go out for dinner. They plan to order equal number of dishes. Each row specifies individual cost. Find the total amount each person needs to pay. Assume the values for this matrix for 3 dishes are 12 23 18 45 32 60 42 39 23 54 42 60 25 84 30 The output will be Amount to be paid by person 1 is 53 Amount to be paid by person 2 is 137 Amount to be paid by person 3 is 104 Amount to be paid by person 4 is 156 Amount to be paid by person 3 is 139 Explanation : Output is the sum of each row Code: BEGIN DECLARE variable arr[5][20], n, sum=0 ___________________ FOR j IN 0 to n-1 DO READ arr[i][j] END FOR END FOR FOR i IN 0 TO 4 DO SET sum = 0 FOR j IN 0 TO n-1 DO sum = sum + arr[i][j] END FOR PRINT "Amount to be paid by person "+(i+1)+" is "+sum END FOR END
B
FOR i IN 0 to 5 DO
C
FOR i IN 0 to n DO
D
FOR i IN 0 to 4 DO
E
FOR i IN 0 to 3 DO

Correct answer: FOR i IN 0 to 5 DO

Explanation

Correct answer: FOR i IN 0 to 5 DO.

Related Accenture Software Engineering questions

Practice more Accenture Software Engineering questions

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