What Can Function Prototypes Do Without Parameters and Return Values?

Click For Summary
SUMMARY

Function prototypes in programming can exist without parameters and return values, serving primarily as procedures that execute code without direct input or output. An example of such a prototype is double func(void), which indicates a function that does not accept any arguments. Despite not returning a value or taking parameters, these functions can perform significant tasks, such as modifying global variables or handling input/output operations. Their utility lies in encapsulating behavior, making code more modular and organized.

PREREQUISITES
  • Understanding of function prototypes in C/C++ programming
  • Familiarity with the concept of procedures in programming
  • Knowledge of global variables and their scope
  • Basic input/output operations in C/C++
NEXT STEPS
  • Explore the concept of procedures in programming languages
  • Learn about global variables and their implications in function design
  • Investigate input/output handling in C/C++ functions
  • Study best practices for writing modular code using functions
USEFUL FOR

Programmers, particularly those working with C/C++, who want to deepen their understanding of function prototypes and their applications in modular programming.

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 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 15 ·
Replies
15
Views
8K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 7 ·
Replies
7
Views
6K