+ 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; }
7 Respuestas
+ 2
Arrays start at index 0.
+ 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.
+ 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..
+ 1
Check it again, it's 20 am getting...
0
Thnx😇
0
But if i input [1] [2]...the result 20 doesn't come...so what can be the problem?
0
Also...i am confused that [1][2] indicate column first,then row or row first, then column?