The reasoning is that the adjective “confident” is most appropriately followed by “of” when we want to express certainty about a fact or outcome. Here, the sentence means that Shyam is sure that he will fail, so “of” is correct.
Option 1: for
“Confident for” is not used in this context and is grammatically incorrect.
Option 2: in
“Confident in” is used when we talk about trust or belief in someone’s ability or something. For example, “She is confident in her skills.” Since “failure” is an outcome and not an ability, this option is not suitable.
Option 3: towards
“Towards” indicates direction or attitude and does not fit the meaning of the sentence.
Option 4: of
“Confident of” expresses certainty about something happening. For example, “He is confident of success.” Similarly, “confident of failure” means he is sure he will fail.