Pls what are functions and parameters. And what does void do to them if used?. Thank u | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Pls what are functions and parameters. And what does void do to them if used?. Thank u

pls I need basic coding examples under c++ to understand better.

14th Dec 2016, 11:19 PM
Michael Dogbey
Michael Dogbey - avatar
4 Respuestas
+ 6
Functions are blocks of code written to perform a certain task. You can pass data into them that they need (called arguments). Any function has a return type, a name, and a list of arguments. Ex: int arrSum(int[] inArr, int arrSize) { //your code return sum; } You would call it like this: arrSum(arr, ARRAY_SIZE); if the return type is void, it doesn't return any value. However, it's a convention to still write return at the end.
14th Dec 2016, 11:57 PM
Tamra
Tamra - avatar
+ 2
Just follow the courses, it's explained.
14th Dec 2016, 11:36 PM
Kabe
+ 2
to give you a simple explanation a function is what goes between the { } and parameters are tha variables and what you do with them in the function. void is the return type for a function that will return nothing.
14th Dec 2016, 11:55 PM
Jason Hoffman
Jason Hoffman - avatar
+ 2
and also follow Kabe's advice, work through the tutorials slowly and methodically making sure you understand them before moving on.
14th Dec 2016, 11:57 PM
Jason Hoffman
Jason Hoffman - avatar