Q:

main.c|4|error C2059: syntax error : 'type'| i dont know y=why this error is popping up

#include <stdio.h>
#include <stdlib.h>

int max(int num1, int num2) {
    int result;
    if(num1 > num2) {
        result =num1;
    } else {
        result = num2;
    }
    return result;
}

int main() {
    printf("%d",max(4,3));
    return 0;
}

I do not understand why this is not working; it is telling me:

main.c|4|error C2059: syntax error : 'type'|

I do not know why this error is popping up.

A:

It would appear that one of the library header files (most likely stdlib.h) is providing a macro definition for max, and this is conflicting with your own function definition.
To resolve this, either rename your function (say mymax) or add the following line after the two #include lines:
#undef max

Or, if you want to  be more thorough:
#ifdef max
#undef max
#endif

Another option, as you aren't actually using anything from the stdlib.h header, is just to remove (or comment out) the #include <stdlib.h> line (but that may affect code you later add to your program).
NOTE: Compilers (such as MSVC) that give macro definitions for max and min are, strictly speaking, not conforming to the C Language Standard. However, that doesn't seem to prevent their implementers from doing it. If you are using MSVC, then you can also prevent this error by including the following line immediately before including the stdlib.h header:
#undef _CRT_INTERNAL_NONSTDC_NAMES
#include <stdlib.h>

You can also fix the problem without changing your code, by adding the /Za complier option (or set "Disable Language Extensions" to "Yes" in the project's C/C++ properties).

