 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to pass individual members of structure as arguments to function in C language?
Passing individual members as arguments to function −
- Each member is passed as an argument in the function call. 
- They are collected independently in ordinary variables in function header. 
Example
#include<stdio.h> //Declaring structure// struct student{    int s1,s2,s3; }s[5]; //Declaring and returning Function// void addition(int a,int b,int c){    //Declaring sum variable and For loop variable//    int i,sum;    //Arithmetic Operation//    for(i=1;i<4;i++){       sum=a+b+c;       printf("Student %d scored total of %d
",i,sum);    } } void main(){    //Declaring variable for For loop//    int i;    //Reading User I/p through For loop//    for(i=1;i<4;i++){       printf("Enter marks for student %d in subject 1 = ",i);       scanf("%d",&s[i].s1);       printf("Enter marks for student %d in subject 2 = ",i);       scanf("%d",&s[i].s2);       printf("Enter marks for student %d in subject 3 = ",i);       scanf("%d",&s[i].s3);    }    //Calling function//    addition(s[].s1,s[].s2,s[].s3); }  Output
day = 2 month = 1 year = 2010
Advertisements
 