- You are required to make a structure named “section”. The names of the two sections are secA and secB.
- There are two members of this structure i.e. numberOfBoys and numberOfGirls.
- In secA there are 48 boys and 6 girls while in secB there are 50 boys and 2 girls.
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 “
include<fstream>include<iostream>struct section
{
int no_boys;
int no_girls;
int sum;
};
section total(section a,section b)
{
section c;
c.sum=c.no_boys+c.no_girls;
return c;
}
int main()
{section secA; section secB; secA.no_boys=48; secA.no_girls=6; secB.no_boys=50; secB.no_girls=2; section func=total(secA,secB); return 0;
}
data.txt”.
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.