Chapter - 9: Arrays

Point out the errors, if any, in the following programs:


K
Sections
1
Exercises

(a)

#include<stdio.h>
int main()
{
	int twod[][] = {
		2, 4,
		6, 8
	};
	printf("\n%d", twod);
	return 0;
}

Error: missing subscript in initialization. It is necessary to mention the second subscript, while 1st is optional.


(b)

#include<stdio.h>
int main()
{
	int three[3][] = {
		2, 4, 3,
		6, 8, 2,
		2, 3 ,1
	};
	printf("\n%d", three[1][1]);
	return 0;
}

Error: missing subscript in initialization. It is necessary to mention second subscript, while 1st is optional.


© 2021 Garbage Valuegarbage value logo