Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4003CEM-Exam-Practise/Functions/functions.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (21 sloc)
809 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
/* | |
Functions can be a value returner or can return nothing. | |
If they return a value, they must be created specifying the value they will return. | |
If they don't need to return anything, they should specify a return type of void. | |
*/ | |
int int_function(int x) { // requires an argument | |
x+=1; | |
return x; // returns int value which has been incremented by +1 | |
} | |
void fuckery(string fuckery_string) { | |
cout << fuckery_string << endl; // just console outputs the fuckery string you passed | |
return; // possible to have a return, but cannot return a value | |
} | |
int main() { | |
// this is a function, the main function | |
cout << int_function(10) << endl; // this console outputs 11 as it is 10+1, run it to find out | |
fuckery("fuck"); | |
return 0; | |
} |