Step 1: Start
Step 2: Define a structure student
with members rno
and perc
Step 3: Declare a structure variable s1
Step 4: Read rno
and perc
from user
Step 5: Call display1
with structure members as arguments
Step 6: Call display2
with structure variable
Step 7: Call display3
with address of structure
Step 8: Display values inside respective functions
Step 9: End
//Passing the address of a structure #include <stdio.h> struct student { int rno; float perc; }; int display1(int, float); int display2(struct student); int display3(struct student *); int main() { struct student s1; printf("Enter Rno. :"); scanf("%d", &s1.rno); printf("Enter Percentage :"); scanf("%f", &s1.perc); display1(s1.rno, s1.perc); display2(s1); display3(&s1); return 0; } int display1(int a, float b) { printf("\n\nPassing Structure Members as arguments :"); printf("\nR.No : %d", a); printf("\nPercentage : %.2f", b); return 0; } int display2(struct student s2) { printf("\n\nPassing Structure as argument :"); printf("\nR.No : %d", s2.rno); printf("\nPercentage : %.2f", s2.perc); return 0; } int display3(struct student *p) { printf("\n\nPassing Structure Address as argument :"); printf("\nR.No : %d", p->rno); printf("\nPercentage : %.2f", p->perc); return 0; }
Enter Rno. : 101 Enter Percentage : 87.5 Passing Structure Members as arguments : R.No : 101 Percentage : 87.50 Passing Structure as argument : R.No : 101 Percentage : 87.50 Passing Structure Address as argument : R.No : 101 Percentage : 87.50