In computer programming, the sole purpose of building any software is to solve a problem existing in the real world and make the world a better place to live in. When we talk about a solution to a problem, it's obvious that we're talking about the procedure to be followed to solve the problem.
Let's consider a case where your teacher comes to you and gives you a bunch of candy, asking you to distribute it equally among your classmates. If you consider this as a problem and try to achieve it with ease, then you might do it as follows:
- Count the number of candies you have.
- Count the number of students present in your class.
- Calculate how many candies should be given to each student.
- Ask all of the students form a queue so that no student can take the required candies twice.
- Start distributing the candies to each student.
- Maintain a separate...