
This means that instead of returning no data, our function will return an integer. You will see that void has been changed to int. First, we have to say what type of data our function will return.

FUNCION TPO CX PROGRAMMER CODE
The C++ code runs similarly, but as usual, requires a bit more information. Note: Much like print() in the earlier example, alert() is also a function. Indentation makes code easier to read, which is very important as your programs become more complex.

White space is not important in JavaScript, but it is customary to indent the code in the function. Any code that falls between the curly brackets is run when the function is called. In JavaScript, the keyword function is used to create functions. Hold on to that thought right now, we will explore functions will parameters later. Your keen eyes might have noticed that print() is also a function, but it is called differently than our function. In the example above, the function runs one line of code. White space matters in Python, so be sure to indent all the code that you want your function to run. The instructions in the function follow on the next line after the colon. The keyword def is used in Python to define and create a function. It will be easier to manage functions and read the code as your program becomes more complex. TIP: give functions names that explain what they do. The purpose of the function is to output "Hello World". In these examples, the function we wrote is called helloFunction. Void functions are used to complete a set of instructions. This simply means that the function does not return a value.

The first type of function that we will look at is a void function. Related: Why Programming Languages Can't Exist Without Functions Void Functions We will show examples in Python, JavaScript, and C++ to demonstrate a range of programming syntax. The exact syntax will depend on the language that you are programming in. There are many different ways to write functions.
