Question

A function sum_matrix_elements(matrix, R,

  • C is designed to sum all elements of a matrix with R rows and C columns. The implementation uses nested loops: total_sum = 0 for i in range(R + 1): # Potential bug here     for j in range(C + 1): # Potential bug here         total_sum += matrix[i][j] Assuming R and C represent the actual number of rows and columns (e.g., R=3 for 3 rows), what kind of error will this code cause?
A TypeError due to incorrect arithmetic.
B KeyError because matrix elements are accessed by key.
C IndexError because the loops attempt to access elements beyond the matrix boundaries.
D ValueError because the sum might exceed integer limits.
E SyntaxError due to incorrect loop syntax.
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)