Individual elements of an array can be passed to a function in the same manner as
ordinary variables. When an array element is passed as an argument, only the
value stored at that specific index is sent to the function.
This approach is useful when a function needs to process a single value from an
array rather than the entire array. The function receives a copy of the value,
and any changes made inside the function do not affect the original array
element.
ordinary variables. When an array element is passed as an argument, only the
value stored at that specific index is sent to the function.
This approach is useful when a function needs to process a single value from an
array rather than the entire array. The function receives a copy of the value,
and any changes made inside the function do not affect the original array
element.
SYNTAX:
void display(int x)
{
printf("%d", x);
}
display(marks[2]);
EXAMPLE:
#include <stdio.h>
void printSingle(int weight) {
printf("Processing one element: %d\n", weight);
}
int main() {
int tinWeight[3] = {10, 20, 30};
printSingle(tinWeight[1]);
return 0;
}