Structure Type Data as Input and Output Parameters:
Structure variables can be passed to functions as parameters in the same manner
as other variables. When a structure is passed to a function, a copy of the
structure is made unless pointers are used.
Structures can also be returned from functions, allowing multiple related values
to be passed back to the calling function as a single unit. This capability
enhances modularity and clarity in program design.
Structure variables can be passed to functions as parameters in the same manner
as other variables. When a structure is passed to a function, a copy of the
structure is made unless pointers are used.
Structures can also be returned from functions, allowing multiple related values
to be passed back to the calling function as a single unit. This capability
enhances modularity and clarity in program design.
EXAMPLE:
#include <stdio.h>
struct Tin {
int id;
float weight;
char grade;
};
void display(struct Tin t) {
printf("ID: %d | Weight: %.2f | Grade: %c\n", t.id, t.weight, t.grade);
}
int main() {
struct Tin t1 = {101, 250.5, 'A'};
display(t1);
return 0;
}