Hi everyone, Pls when do we use the 'void' function at what instance do we use it?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hi everyone, Pls when do we use the 'void' function at what instance do we use it??

17th Feb 2017, 2:10 PM
Ubamadu Possible
Ubamadu Possible - avatar
4 Answers
+ 7
Maybe you just want to display a message like a menu for example, or you use parameters by reference so they modify without having to return anything, or working with arrays (like sorting or setting values to it). The posibilities are many 😉
17th Feb 2017, 2:19 PM
C.E.
C.E. - avatar
+ 4
when the function doesn't return anything (no return bla; in the function).
17th Feb 2017, 2:14 PM
Mario L.
Mario L. - avatar
+ 3
If you don't want to return a value like intergers u can use void. If u want to return a string or a char you can use void.I hope this helps,and I don't know a better way to explain that.😕
17th Feb 2017, 2:15 PM
Julian Aung
Julian Aung - avatar
+ 1
If you want to perform an action without returning a value. Examples like printing/displaying results, sorting arrays passed by reference etc.
18th Feb 2017, 3:33 AM
abdication
abdication  - avatar