Question
A C function print_matrix(int rows, int cols, int
matrix[rows][cols]) is designed to print a matrix. #include void print_matrix(int rows, int cols, int matrix[rows][cols]) { Â Â for (int i = 0; iSolution
Correct Answer: B (The outer loop i <= rows will iterate for i = 0, 1, 2. For i = 2, it tries to access matrix[2], which is out of bounds for a 2-row matrix (indices 0 and 1).) • Dry Run: o Call print_matrix(2, 3, my_matrix): rows is 2, cols is 3. o The outer loop for (int i = 0; i <= rows; i++) will iterate for i = 0, i = 1, and i = 2. o When i = 0: The first row (matrix[0]) is printed correctly. o When i = 1: The second row (matrix[1]) is printed correctly. o When i = 2: The loop attempts to access matrix[2]. For a 2x3 matrix, the valid row indices are 0 and 1. Accessing matrix[2] is an out-of-bounds memory access. o This out-of-bounds access will lead to undefined behavior, most likely a segmentation fault (program crash). • Why Correct Answer (B): It will print the matrix and then attempt to access memory out of bounds, potentially causing a segmentation fault. o The first two rows will be printed correctly. Then, the loop will try to access a non-existent third row (matrix[2]), causing a memory access violation.
How many countries participated in the International Maritime Defence Expo mentioned in the file?Â
Which organization's Director (Finance) has recently assumed the additional charge of Chairman and Managing Director of the company, according to the in...
On which date did the Border Roads Organisation (BRO) connect the strategic Nimmu-Padam-Darcha road in Ladakh?Â
What was India’s National Index score in the Ipsos Consumer Confidence Survey referenced in the report?Â
Indian Space Research Organisation (ISRO) and IN-SPACe for the successful launch of India's maiden private rocket Vikram-Suborbital developed by ______.
According to the information provided by the Ministry of Defence (MoD),the total value of defence production in the 2022-23 financial year has exceeded ...
The Gyan Bharatam National Manuscript Survey (GBNMS) is planned for a duration of:Â
Bank of Baroda’s UPI-linked credit line for women SHGs provides an overdraft up to:Â
What was the major update from the RBI in the first quarter of FY 2025-26?Â
What was the revised economic growth forecast for India in FY2024-25 as per the latest RBI report?