My friend wants an old assignment which I have done few semesters ago. I want to know whether it's ok to give the assignment to him and whether it's going to be a problem for me in the future. (I have already done that subject, but still following the degree) Please let me know.
There is no single right answer here. The answer depends from university to university, and even from faculty member to faculty member. For example, one professor in my department believes everything should be sharable, while another believes that it's wrong to share old materials.
So you'll need to see what the policy of the instructor teaching your friend's class is.
If an instructor returns an assignment to a student. The instructor cannot possible expect the student to hide the results. This is one reason why many instructors do not allow students to keep a mid-term or final exam.
As long as your friend does not try to submit the work as his own this should not be a problem. This is assuming of course that there is no policy at your institution about this matter.