i had a quiz ,im confused about answer..can you please clarify which of the following is true? with reason

1. int a[ ][ ] ={{2,3},{3,4},{4,5}};
i. It will create a 3*2 matrix and initialize it
ii. It will create a 3*2 empty matrix
iii. It will actually create a single dimensional array with six values
iv. None of the above

2. int a[2][2] ={2,3,3,4,4,5};
i. Will create a 2*2 matrix of integers initialized with first four elements
ii. Will generate a run time error
iii. Will generate a compile time error
iv. None of the above

3. char a[3][2] ={‘a’,’\0’, ‘b’,’\0’, ‘c’,’\0’};
cout << *a ;
i. Will print “abc”
ii. Will print “a”
iii. Will print “b”
iv. Will print “c”
v. None of the above

What are your answers? Instead of us just telling you the answers you should try to figure them out yourself, post the answers, and we'll grade your work or answer questions about what you don't understand.

1. int a[ ][ ] ={{2,3},{3,4},{4,5}};
i. It will create a 3*2 matrix and initialize it
ii. It will create a 3*2 empty matrix
iii. It will actually create a single dimensional array with six values
iv. None of the above


i think the answer is iv, as it will not create any place in the memory

2. int a[2][2] ={2,3,3,4,4,5};
i. Will create a 2*2 matrix of integers initialized with first four elements
ii. Will generate a run time error
iii. Will generate a compile time error
iv. None of the above

according to me the answer is iii , as compiler give it as an error of too many initializers

3. char a[3][2] ={‘a’,’\0’, ‘b’,’\0’, ‘c’,’\0’};
cout << *a ;
i. Will print “abc”
ii. Will print “a”
iii. Will print “b”
iv. Will print “c”
v. None of the above

ii print a .. :(

please clarify im wrong

1. int a[ ][ ] ={{2,3},{3,4},{4,5}};
i. It will create a 3*2 matrix and initialize it
1. 2.
1. [ [2][3] ] //<-- one way to think about it.
2. [ [3][4] ] //3 x 2
3. [ [4][5] ]

Try writing some simple programs and find out for yourself.

i have no idea please help :(

>> i have no idea please help :(

Ancient Dragon's right. Try it yourself first. #2 and #3 should not have been posted. All you had to do was compile and run them and you'd know the answers. #1 is less obvious.

Now what precisely is your question? You need to articulate more than "I have no idea".

just tell me my answers are right or not

>> just tell me my answers are right or not

Presumably you've already gotten the test back so you know the answers. You don't need anyone to tell you the answers to 2 or 3, so I'm not going to tell you. As for #1, regardless of whether you may have lucked out and accidentally guessed the correct multiple choice answer, your explanation is wrong, so if you have any interest in being a programmer, do some research and stop expecting to be spoon fed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.