Lesson 30: Saying yes and no with うん, ううん, はい, いいえ, ええ, and いや
The exact situations where different yes/no words are used are pretty much entirely dependent on convention. As such, the rules are too complicated to teach. But I can give a rundown of the common yes/no words anyway.
うん - Yep (casual)
ううん - Nope (casual)
うん and ううん have completely different tones of voice when spoken.
はい - Yes (general use)
いいえ - No (polite)
ええ - Yeah (informal, kind)
いや - No (rough)
Warning: ええ can be an unrelated filler word that feels like the speaker has something to elaborate on or deny, or that they're confused.
In addition to "no", 嫌 いや is also a な-adjective used for unlikeable things.
嫌だ! いやだ! No!
嫌なことしないでください Please don't do something bad.
いや can also be said as や. This usually isn't done if it'd be confusing.