/* Example 2: User Input for a 2D Array */
#include <stdio.h>
int main() {
int rows, cols;
// Ask user for the size of the array
printf("Enter number of rows and columns: "); scanf("%d %d", &rows
, &cols
); int matrix[rows][cols];
// Input elements into the 2D array
printf("Enter elements of the matrix:\n"); for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
scanf("%d", &matrix
[i
][j
]); }
}
// Print the 2D array
printf("The entered matrix is:\n"); for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
}
}
return 0;
}
LyogRXhhbXBsZSAyOiBVc2VyIElucHV0IGZvciBhIDJEIEFycmF5ICAqLwojaW5jbHVkZSA8c3RkaW8uaD4KaW50IG1haW4oKSB7CiAgICBpbnQgcm93cywgY29sczsKICAgIC8vIEFzayB1c2VyIGZvciB0aGUgc2l6ZSBvZiB0aGUgYXJyYXkKICAgIHByaW50ZigiRW50ZXIgbnVtYmVyIG9mIHJvd3MgYW5kIGNvbHVtbnM6ICIpOwogICAgc2NhbmYoIiVkICVkIiwgJnJvd3MsICZjb2xzKTsKICAgIGludCBtYXRyaXhbcm93c11bY29sc107CiAgICAvLyBJbnB1dCBlbGVtZW50cyBpbnRvIHRoZSAyRCBhcnJheQogICAgcHJpbnRmKCJFbnRlciBlbGVtZW50cyBvZiB0aGUgbWF0cml4OlxuIik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IHJvd3M7IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgY29sczsgaisrKSB7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZtYXRyaXhbaV1bal0pOwogICAgICAgIH0KICAgIH0KICAgIC8vIFByaW50IHRoZSAyRCBhcnJheQogICAgcHJpbnRmKCJUaGUgZW50ZXJlZCBtYXRyaXggaXM6XG4iKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcm93czsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBjb2xzOyBqKyspIHsKICAgICAgICAgICAgcHJpbnRmKCIlZCAiLCBtYXRyaXhbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==