In C, a function can return only one value using the return statement. However,
by using pointers as parameters, a function can produce multiple output values.
Such parameters are known as output parameters.
When a pointer is passed to a function, the function can modify the value stored
at the memory location pointed to by the pointer. These changes are reflected in
the calling function, allowing data to be returned indirectly.
by using pointers as parameters, a function can produce multiple output values.
Such parameters are known as output parameters.
When a pointer is passed to a function, the function can modify the value stored
at the memory location pointed to by the pointer. These changes are reflected in
the calling function, allowing data to be returned indirectly.
SYNTAX:
void function(type *param)
{
*param = value;
}
EXAMPLE:
#include <stdio.h>
void addtins(int *p,int tin){
*p = *p +tin;
}
int main() {
int total_tins=100;
printf("Before Function: %d\n",total_tins);
addtins(&total_tins,50);
printf("After Function: %d",total_tins);
return 0;
}