1. You are required to make a structure named “section”. The names of the two sections are secA and secB.
  2. There are two members of this structure i.e. numberOfBoys and numberOfGirls.
  3. In secA there are 48 boys and 6 girls while in secB there are 50 boys and 2 girls.
  4. Write a function totalBoysAndGirls(). It takes two arguments by value. These arguments are the two section structures. Pass structures secA and secB to this function to calculate the total number of boys and total number of girls in the computer programming course and returns this sum in a structure of type section. Write the output of this function in a file “



    struct section
    int no_boys;
    int no_girls;
    int sum;
    section total(section a,section b)
    section c;
    return c;
    int main()

        section secA;
        section secB;
        section func=total(secA,secB);
        return 0;


Write a function totalStudents() . It takes one argument by address. This argument is a pointer to the section structure. This function gives the sum of total number of students in the section or class. Pass the result of the previous step i.e. the structure in which you found the total number of boys and girls in the computer programming course. Use this function to find the total number of students in the computer programming course. Write the output of this function in the same file “data.txt”.
Please give your suggestions and need help.

5 Years
Discussion Span
Last Post by Ancient Dragon

Your function total() is incomplete. After declaring section c you need to populate its members with totals from a + b then you can calculate the sum as you have coded it. The sum can't be calculated until no_boys and no_girls are known.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.