answersLogoWhite

0

Functions hold code, which means anything that happens within a function can be "called" later on. Allowing the programmer to save time, and ensuring he doesn't have to re-write code. Example:

Instead of writing "Hello" 10 times, I made a function that said print("hello") 5 times, then "Called" the function twice.

def helloFiveTimes():

print("Hello")

print("Hello")

print("Hello")

print("Hello")

print("Hello")

return

helloFiveTimes()

helloFiveTimes()

User Avatar

Wiki User

8y ago

What else can I help you with?

Continue Learning about Engineering

What is called Dividing a program into function and modules?

Modularisation. It could also be called refactoring, where large and complex functions are split into several simpler functions, making code easier to read. Refactoring can also help to reduce code duplication.


How do you draw shapes in a c program?

With platform-dependent library-functions. Use your help system.


Why must we reuse?

To help our earth.


How do you code a program to scan a number n and then output the sum of the power from 1 to n?

help me now !!


Functions in C Language?

Functions have many uses. Although it is possible to write all code within a single function (the main function), code becomes harder to read. By separating the code into smaller, simpler functions with meaningful descriptive names, complex code becomes that much easier to both read and maintain. That is, the code becomes self-documenting so there is less need for comments which would otherwise become a distraction. Each function should be designed such that it does the absolute minimum amount of work required to fulfil its purpose and does that work as efficiently as possible. Although functions can be expensive to call and return, a well-written function can be inline expanded by the compiler thus eliminating the function call altogether. Thus functions become a programming tool which can drastically reduce the amount of duplicate code we need to write. Ideally, a function should be small enough so that all the code within that function will fit on screen at once. This usually means writing a huge number of low-level functions that do very little work by themselves, and then using these low-level functions as the building blocks for more complex, higher-level functions.

Related Questions

How do modules help you reuse code in a program?

MODULES ALSO REDUCE THE DUPLICATION OF CODE WITHIN A PROGRAM..THIS BENEFIT OF USING MODULES IS KNOWN AS code reuse BECAUSE YOU ARE WRITING THE CODE TO PERFORM A TASK ONCE AND THEN REUSING IT EACH TIME YOU NEED TO PERFORM A TASK.


How do module help reuse code in a program?

MODULES ALSO REDUCE THE DUPLICATION OF CODE WITHIN A PROGRAM..THIS BENEFIT OF USING MODULES IS KNOWN AS code reuse BECAUSE YOU ARE WRITING THE CODE TO PERFORM A TASK ONCE AND THEN REUSING IT EACH TIME YOU NEED TO PERFORM A TASK.


What is the multimedia software program Adobe used for?

Adobe is used for various functions on a computer, one of the basic functions is to help turn code into readable content.


What is called Dividing a program into function and modules?

Modularisation. It could also be called refactoring, where large and complex functions are split into several simpler functions, making code easier to read. Refactoring can also help to reduce code duplication.


Why do we use functions in programming and how do they help in organizing and reusing code effectively?

Functions in programming are used to group together a set of instructions that perform a specific task. They help in organizing code by breaking it into smaller, more manageable parts. This makes the code easier to read, understand, and maintain. Functions also promote code reusability, as they can be called multiple times from different parts of the program without having to rewrite the same code. This helps in saving time and effort, and ensures consistency in the codebase.


How do you draw shapes in a c program?

With platform-dependent library-functions. Use your help system.


Why we write java program using classes?

Classes are well organised functions in java which help discriminate between two different functions.


Why must we reuse?

To help our earth.


Where is the best place for you to find information about the features and functions of a program you are using?

the appilcation's help menu


Which plastic bottles are safe to reuse?

Plastics can be very dangerous because of the chemicals contained in many. Therefore, a number code system has been used to help identify which plastics are safer than others to reuse. 1, 2, 4, and 5 are considered safe, while 3, 6, and 7 are those we should not reuse.


How does using wind power help the reuse reduce recycle program?

It really doesn't help recycling. That said, wind power does reduce air pollution and fossil fuel consumption that are caused by conventional power plants.


Why constant is used?

Constants are used in programming to store values that remain unchanged throughout the execution of the program. Constants help improve code readability, make maintenance easier, and prevent accidental changes to these values. It also allows developers to reuse these fixed values across different parts of the program.