Functions: Difference between revisions
No edit summary |
wikademia>Wikademia m 13 revisions |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
This | This page is about computer programming functions. For mathematical functions, see [[Functions (mathematics)]]. | ||
< | This example is on functions. With Functions you need to state the return type of the function. Either int or void. Int is value used for returning something to a call, mainly used for returning integers such as the add function in the following program. Void is used for functions that don't return a value or you don't want to return a value. You must use int or void in every function you make. Take a look at the following program: | ||
<source lang="c"> | |||
#include <stdio.h> | #include <stdio.h> | ||
| Line 24: | Line 26: | ||
return 0; | return 0; | ||
} | } | ||
</ | </source> | ||
You could have done this(it really doesn't make a difference): | You could have done this(it really doesn't make a difference): | ||
< | <source lang="c"> | ||
#include <stdio.h> // | #include <stdio.h> //standard C header | ||
int cfile(char *file) | int cfile(char *file) | ||
| Line 51: | Line 53: | ||
return 0; | return 0; | ||
} | } | ||
</ | </source> | ||
==See also== | |||
*[[Functions and Recursion]] | |||
*[[Procedures and functions]] | |||
*[[Functions and Subroutines in VB6]] | |||
*[[Functions and Methods]] | |||
*[[Basic Python Functions]] | |||
*[[Web Design/Dynamic Websites/Simple Functions in PHP]] | |||
*[[25 Essential PHP Functions]] | |||
*[[Introduction to Object-Oriented PHP]] - A primer on creating reusable code using classes and objects. | |||
[[Category:Programming]] | |||