For example: if someone was fasting and they prayed fajr then slept through dhuhr prayer and asr prayer (missed both prayers) then woke up and prayed maghrib (then ate to break the fast) and then prayed isha. This means that they missed 2 out of 5 fard prayers while they were fasting. Is their fasting valid? Or invalid because he didn't pray all the prayers?
2 Answers
Fasting and prayer are basically and from a fiqh perspective two independent acts of worship. Each of them has special conditions for validity/invalidity (one may say technical conditions as fiqh is based on the knowledge we have, but none of us knows to how much extent Allah may forgoe or not).
Note that none of us even knows whether our best worship is even partially accepted by Allah therefore scholars say that a believer lives between fear and hope: the fear that his best deeds won't be accepted and the hope that Allah the Almighty and most Merciful will accept them. This is why one should never neglect one worship while concentrating on another one. It's not good to fast without praying nor to pray without fasting as both are ordered by Allah.
As for the conditions that may make a fast invalid they, are related to having intercourse or any thing that leads to semen emission (be it legal or not) or eating or drinking during the day time of a fasting day.
Note that if you missed a prayer you are asked to pray it once you remember it as it is a due on you. You can't just skip it especially if you have not just forgotten it. Missing to pray on time isn't a reason not to pray a prayer later as you may pray it qada'.
Fasting and Prayer are independent acts missing one does not invalidate another. Fasting is only invalidated by intercourse, masturbation, menstruation, post-childbirth bleeding and deliberately eating, drinking and vomiting.