What do you mean by prototype of a function

What do you mean by prototype of a function.

function declaration or prototype in C tells the compiler about function name, function parameters and return value of a function. The actual body of the function can be defined separately.
Here is the syntax of function declaration:

return_type function_name(type arg1, type arg2 .....);

Like variable in C, we have to declare functions before their first use in program.

Important points about function declaration.

  • Function declaration in C always ends with a semicolon.
  • By default the return type of a function is integer(int) data type.
  • Function declaration is also known as function prototype.
  • Name of parameters are not compulsory in function declaration only their type is required. Hence following declaration is also valid.
    int getSum(int, int);
  • If function definition is written before main function then function declaration is not required whereas, If function definition is written after main function then we must write function declaration before main function.

What is difference between Call by value and Call by reference in C.

Call by Value

In call by value method a copy of actual arguments is passed into formal arguments in the function definition. Any change in the formal parameters of the function have no effect on the value of actual argument. Call by value is the default method of passing parameters in C. Different memories are allocated for the formal and actual parameters.
Here is an example of call by Value

 
void getDoubleValue(int F){
   F = F*2;
   printf("F(Formal Parameter) = %d\n", F);
}

Call by Reference

In call by reference method the address of the variable is passed to the formal arguments of a function. Any change in the formal parameters of the function will effect the value of actual argument. Same memory location is accessed by the formal and actual parameters.
Here is an example of call by reference

void getDoubleValue(int *F){
   *F = *F + 2;
   printf("F(Formal Parameter) = %d\n", *F);
}