I want to know what is difference between "who and whom"? I already searched in the dictionary. But I am confused using these two words. What is the difference?
There are probably more nuances, but I won't overwhelm you with every single possible use case, so here's the most basic breakdown of it: "who" is for subjects, and "whom" is for objects.
Some languages don't really make a distinction, and without knowing your native language, I can't draw any parallels or try to make examples, but in English (and many other languages), when you have a verb, the actor is called the subject and the target being acted upon is called the object. So, for example, when you say "I eat the apple", the term "I" is the subject, and "the apple" is the object. Note that it's the actor and target of the verb itself - it can be confusing in examples like this:
The apple was eaten by me.
Notice how I used "me" here and not "I". That's because "the apple" is now the subject - the verb is "was" (past tense of "to be"), so the apple performed the action "to be", where the state it was being was "eaten, (by me)".
So, when you want to distinguish between "who" and "whom", it is literally the same.
Who ate the apple?
The apple was eaten by whom?
(These two aren't exactly the same; the second sentence would usually be said with emphasis on "whom" as though to express surprise or shock at who ate the apple.)
In pretty much all cases where "who/whom" is being used as a noun and not a specified (in the sentence "the person who ate the apple", "who" is not actually a noun, so keep that in mind), you can just apply the same rules as all other subject/object distinctions.
"I ate the apple." => "Who ate the apple?"
"The apple was eaten by him." => "The apple was eaten by whom?"
Final note - if you hear native English speakers use "who" where "whom" should be used, that is because many of us are too lazy to actually care or maybe didn't even actually learn this. If you just use "who" everywhere, you likely will not be corrected (or even noticed), but it is a good idea to learn the rules before using native colloquial slangs, shortcuts, etc.
There is one exception; at least to me, "the apple was eaten by who?" sounds mostly fine, but "the person with who I talked" sounds extremely awkward. If you are placing a preposition right before who/whom as an object, I still think you should use "whom". I usually just use "who" everywhere because I'm lazy, but this is the one case where I will always use "whom" properly and will find it awkward if I hear it the other way around (so the correct phrase is "the person with whom I talked").