What Can Function Prototypes Do Without Parameters and Return Values?

AI Thread Summary
Function prototypes can exist without parameters or return values, serving as procedures that execute specific code without needing input or output. An example is a function defined as double func(void), which does not take any arguments. Such functions can still perform tasks like modifying global variables, handling user input, or managing side effects without returning data to the caller. They are useful in scenarios where the function's purpose is to execute a series of commands rather than compute a value. Overall, these functions emphasize the versatility of coding practices beyond traditional input-output models.
Luongo
Messages
119
Reaction score
0
Just some basic questions i have about function prototypes (functions)
What's an example of a code which has no parameters? ie: double func(void)
what is the purpose if the thing doesn't take in parameters? also, what if there is keyboard input and screen input what does that mean in the function prototype? does it usually happen? what's the point of having a function if it doesn't RETURN any useful stuff to main? or prints nothing on the screen?
 
Physics news on Phys.org
A function can still do lots of things, even without parameters and returning a value. It will execute whatever code is in the function.

In this way it's basically a Procedure.
 

Similar threads

Replies
2
Views
2K
Replies
5
Views
2K
Replies
15
Views
2K
Replies
15
Views
3K
Replies
15
Views
7K
Replies
7
Views
6K
Back
Top