Preview:
#include <iostream>
using namespace std;

int factorial(int num); // <-- remember to include semicolon  

// we use prototype of the function to hold the function itself after the main function and show that there is a function with similar name and fuctionality when come across first time.


int main()
{
	int n, k, result;

	cout << "Please enter the n and k by space" << endl;
	cin >> n >> k;


	result =  factorial(n) / (factorial(k)*factorial(n-k));

	cout << "The result is " << result << endl;

	return 0;
}

int factorial(int num) {
	int i, factRes;
	factRes = 1;

	for (i = 1; i <= num;i++) {
		factRes *= i;
	}

	return factRes;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter