I'm new to Cross Validated SE. I've asked this question and got 2 down votes. So, I'm asking if it was an off-topic question or if there is a better way to ask it.
I'm not sure that your question deserves two downvotes. Your question is from a course or textbook, so it qualifies as 'homework' for our purposes. You should add the
[self-study] tag & read its wiki. That said, you certainly don't hide that fact, and aren't just after the answer / someone to do your homework for you. You do tell us what you understand thus far, what you've tried & where you're stuck, which is what we request.
One other possible issue is that you present an image of the question, rather than retyping the question as text. You should do so instead of just posting a photograph (see here).
You could also use a better title, as @mkt suggested.
Abdu, I was one of the original downvoters, because I believed that your question was posed poorly (and as I commented, the title not reflecting the question bothered me). I undid the downvote after the editing both by you and by @gung addressed this. Reflecting on this, I may have reacted too quickly by downvoting; giving you the chance to edit first would have been fairer to you.