In both the given circuits, A and B are the inputs and Y is the output.

Hence, the output of the combination of the two NAND gates is given as:

Hence, this circuit functions as an AND gate.
(b)A Bar is the output of the upper left of the NAND gate and B Bar is the output of the lower half of the NAND gate, as shown in the following figure.

Hence, this circuit functions as an OR gate.