-1
int f( int i ) {
    printf("called f\n"); 
    if (i < 0) return -i; 
    else
    return 3 * i;
 }

I just want to know what int "f" means.

SpriteAbi
  • 19
  • 1

2 Answers2

2

Basically, int f(int i) means :

  1. The first "int" is the type of the result returned by the function, aka -i or 3 * i with a type of "integer".
  2. "f" is the name of the function. It could be whatever you want, for example "function".
Batche
  • 65
  • 1
  • 8
2

It is just the name of the function that was declared. In this case it is a function that returns an integer. We could declare the same one with a different name:

int name() {
    return (1 + 2);
}

The function that you provided is most likely used in the main() function, like this:

int main(){
    int x = 2;
    int output = f( x );
    printf("%d", output);
    return 0;
}
Nox5692
  • 150
  • 8