Bifalgorithm post · Computer science one · Void Functions

How are void functions defined in C?

How are void functions defined in C? (Computer science one · Void Functions) — "18.1.2. Void Functions\n\nThe keyword void can be used in C to indicate a funct…

Ideas in this flowchart

  • Void functions in C
  • A void function does not return a value.
  • Including a return statement is good practice, although it is not necessary.
  • A void function can have no input parameters.
  • Example: defining the void function printCopyright.
  • Prototype: void printCopyright();
  • Definition: void printCopyright() { printf("(c) Bourke 2015"); return; }
  • An explicit void parameter can indicate that the function takes no parameters: void printCopyright(void);
Feed/

How are void functions defined in C?

No cover

Channel

Computer science one

1 page

"18.1.2. Void Functions\n\nThe keyword void can be used in C to indicate a function does not return a value, in which case it is called a “void function.” Though it is not necessary, it is still good practice to include a return statement.\n\n//prototype:\n\nvoid printCopyright();\n\n//definition:\n\nvoid printCopyright() {\n\nprintf(\"(c) Bourke 2015\n\n\");\n\nreturn;\n\n}\n\nIn the example above, we’ve also illustrated how to define a function that has no inputs. Some sources may include an explicit void keyword as a parameter to indicate the function takes no parameters as in void printCopyright(void); ."

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.