You may assume that when picking the five people, order in which you picked them doesn't matter, and you will never pick the same person more than once.
In a discrete probability setting like this, you may count the number of possible ways an event occurs with the condition you are interested in and divide by the number of possible ways the event can occur without any regard to the condition in question.
How many ways can you pick five people of this class where none are mechanical engineering? There are $51$ such people from which you want to choose $5$ of them. As such, there are $\binom{51}{5}$ ways you can do this.
How many ways can you pick five people of this class where you don't care what major they are? There are $100$ people in the class from which you want to choose $5$ of them. As such, there are $\binom{100}{5}$ ways you can do this.
For a final answer of:
$$\frac{\binom{51}{5}}{\binom{100}{5}} = \frac{51\cdot 50\cdot 49\cdot 48\cdot 47}{100\cdot 99\cdot 98\cdot 97\cdot 96}$$
An equivalent method of finding the solution is to consider the probability of at each step picking another person who matches our criterion of not being a mechanical engineering major.
At step 1, we have a $\frac{51}{100}$ chance of picking a non-mechanical engineering major (since there are 51 non mechanical engineering majors out of 100 people to choose from).
After having picked that person, there are only 50 remaining non mechanical engineering majors out of 99 remaining people total. So, in step 2 we have a $\frac{50}{99}$ chance of picking one of those people.
Similarly for steps 3 through 5 there will be a $\frac{49}{98},\frac{48}{97},$ and $\frac{47}{96}$ chance of continuing to pick non mechanical engineering majors.
To have successively picked non mechanical engineering majors at every step along the way corresponds to multiplying these probabilities together for again a final answer of $\frac{51\cdot 50\cdot 49\cdot 48\cdot 47}{100\cdot 99\cdot 98\cdot 97\cdot 96}$, agreeing with our answer from before.