Answer: The noun clause functions as the direct object in sentence B. The soldiers carried whichever flag belonged to their country.
Explanation: A noun clause is a dependent clause, that is to say a clause that cannot stand alone as a sentence because it does not express a full thought. Moreover, a noun clause functions as a noun and it is introduced by a relative pronoun, such as "what", "who" and "whichever". Furthermore, it can act as subject of a sentence, direct object or even indirect object.<u> In sentence B., the noun clause ("whichever flag belonged to their country") is acting as the direct object because it is the recipient of the transitive verb "carried" and it comes after it. </u>