Here are the steps to solve this problem:
1. Declare and initialize a 2D array to store roll numbers and marks of 5 students in 5 subjects.
2. Write a loop to input roll numbers and marks from the user.
3. Calculate the average of each student by summing marks of all subjects and dividing by total subjects.
4. Write if conditions to check averages above 80 and below 40 and print appropriate roll numbers and averages.
5. Calculate overall average by summing averages of all students and dividing by total students.
6. Print the overall average.