Overview of Functions in C++
Pass by value/copy
Pass by reference using &, the referencing operator.
Pass arrays by using the dereferencing operator *.
Improve documentation by using #define.
Pre-conditions (Conditions Before the function is executed)
Post-conditions( Conditions After the function is executed)
Searching and Sorting:
Linear Search
Binary Search
Selection Sort.
Example of recursion and #define:
In the header file:
Preserves int Fibonacci(Preserves int N);
In the Implementation file:
#define Preserves
#define Produce
Produce int Fibonacci( Preserves int N)
{
if (N <= 2)
return 1;
else
return Fibonacci(N-1) + Fibonacci(N-2);
}//end Fibonacci
In the driver file:
#include <iostream.h>
#define Happy cout
#define New <<
#define Year "Here they are:\n"
#define Preserves
#include "Fibonacci.h"
void main()
{
int N;
cout << "How many Fibonacci number you want?\n";
//Comments ,, type something to explain ,, what you doing....;
cin >> N;
Happy New Year; // cout << "Here they are:\n"
for (int i = 0; i<N; i++)
cout << Fibonacci(i+1) << "\t";
cout << endl;
}//end main