Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
53 views
in Computer by (44.8k points)
closed by

How to reduce redundancy using Functions?

1 Answer

+1 vote
by (44.9k points)
selected by
 
Best answer

To illustrate this, let us take a very basic human habit of drinking water.

If we look at the action of drinking water, it involves 4 main steps only:

  • Take a glass of water. 
  • Sip the water from the glass. 
  • Gulp the water down the throat. 
  • Put down the glass when we are no longer thirsty.

Although the action “Drink water” constitutes of 4 steps, yet while describing our day today life routine to someone else, we use the phrase like “Drink water”. This action of “Drink water” is easy for the other person to understand and covers up the above 4 steps in a single action. Thus, every time we include “Drink water” in our routine, it will automatically cover the above 4 steps.

Similarly, the main idea behind using a function in your code is to keep the code DRY (Don’t Repeat Yourself). Cutting out repeated commands helps to minimize errors, keeps code short, and saves programming time.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...