*** Systems ***
OS: Windows 8.1 64bit
IDK: MS Visual Studio Express 2013 for Windows Desktop

Problem: I created a simple (very simple) User-defined function named func_compare that compares two numbers, it has two parameters of type Integer.
It has no errors whatsoever until you compile it, and it says identifier func_compare not found.
It seems to me that my compiler does not know that it was actually a user-defined function. I am also suspecting that my IDK is missing some components???

Here is my code;


#include <iostream>
using namespace std;

int main(){

    int num1, num2;
    cout << "Enter two numbers: ";
    cin >> num1 >> num2;
    int larger;
    larger = func_compare(num1, num2);
    cout << larger << endl;

    return 0;

//here is my user-defined function
int func_compare(int x, int y){

    if (x > y)
        return x;

        return y;
        cout << "The numbers are equal!";


If you define function after call it, then declare it before
e.g. put line int func_compare(int x, int y); before main()

I was too silly for not reading my book farther as the answer was actually right there. Thanks AndrisP, this thread is solved.

Either I declare the functions first before the definition or function definition first before calling it.

This question has already been answered. Start a new discussion instead.