A friendly place for programming greenhorns!
2-D array of boolean
as a boolean variable can have only two values-true,false..so why exactly do we need an array of boolean values.???
I cooked this example up. I dont know if it will be of much use in the real-world. hth

There is a building of [3] floors , each having [4] rooms with just 1 bulb in each room. Bulb can be true/false. Now find out in which room light is on and tell that person to go to sleep.

output :

PS : The problem you mentioned doesnt really need an example. but it doesnt hurt to imagine. good luck and thanks for the practice i had due to you !
To make this a 3D problem, just add multiple bulbs to a room.

boolean b[3] is an array that CAN hold 3 references to boolean variables.

boolean b[3] [ ] is an array of 5 references to boolean arrays - its like : " b[3] {b1[], b2[],b2[]} " . The size of b1, b2, b3 can be different.
b[1] , b[2] , b[3] are a references to boolean arrays and NOT 3 booleans. b[1] [3] , that is a boolean. I guess this is where you have misunderstood.

boolean b[3] [ ] [ ] is like " b[3] {b1[ ] [ ], b2 [ ] [ ] , b3 [ ] [ ]} " etc...

Subhendu Dash wrote:as a boolean variable can have only two values-true,false..so why exactly do we need an array of boolean values.???

Your question is a bit strange. The fact that a boolean can only be true or false does not have anything to do with being able to create an array of boolean values.
(1 like)
you need an array (or better, you can USE an array) any time you need to remember more than one instance of a variable. I may have an array of booleans to hold whether a group of students have paid their dues. I need to recall a yes or not values for EACH student.
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter

This thread has been viewed 4442 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 21, 2018 00:37:51.