+ 1

Why 2nd printf values unknown number..why not from arrays?can anyone plz clear me the topic

#include <stdio.h> int main() { int a[2][3] = { {3, 2, 6}, {4, 5, 20} }; printf("Element 3 in row 2 is %d\n", a[1][2]); printf("Element 3 in row 2 is %d\n", a[2][2]); return 0; }

26th Jul 2020, 4:43 PM
Muhtasinul
Muhtasinul - avatar
7 Respuestas
+ 2
Arrays start at index 0.
26th Jul 2020, 4:50 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Muhtasinul in two-dimensional arrays it is row first, then column. So [1][2] is the address of the second row, third column. Study carefully Jayakrishna🇮🇳's answer.
15th Sep 2020, 3:49 PM
Brian
Brian - avatar
+ 1
int a[2][3]; Colomn indexes 0. 1. 2 Row index: 0: {3 , 2, 6}, 1: {4, 5, 20} Max index is a[1][2]. Next a[2][2] invalid so garbage value..
26th Jul 2020, 4:58 PM
Jayakrishna 🇮🇳
+ 1
Check it again, it's 20 am getting...
26th Jul 2020, 5:04 PM
Jayakrishna 🇮🇳
0
Thnx😇
26th Jul 2020, 5:00 PM
Muhtasinul
Muhtasinul - avatar
0
But if i input [1] [2]...the result 20 doesn't come...so what can be the problem?
26th Jul 2020, 5:01 PM
Muhtasinul
Muhtasinul - avatar
0
Also...i am confused that [1][2] indicate column first,then row or row first, then column?
27th Jul 2020, 2:10 PM
Muhtasinul
Muhtasinul - avatar