Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with my home work: # 1 For research purposes and to better help s

ID: 3545480 • Letter: P

Question

Please help me with my home work:

# 1

For research purposes and to better help students, the admissions office of your local university wants to know how well female and male students perform in certain courses. You receive a file that contains female and male student GPAs for certain courses. Due to confidentiality, the letter code f is used for female students and m for male students. Every file entry consists of a letter code followed by a GPA. Each line has one entry. The number of entries in the file is unknown. Write a program that computes and outputs the average GPA for both female and male students. Format your results to two decimal places. Your program should use the following functions:

a.       Function openFiles: This function opens the input and output files, and sets the output of the floating-point numbers to two decimal places in a fixed decimal format with a decimal point and trailing zeros.

b.      Function initialize: This function initializes variables such as countFemale, countMale, sumFemaleGPA, and sumMaleGPA.

c.       a. Function sumGrades: This function finds the sum of the female and male students

Explanation / Answer

(4)

#include<iostream>
using namespace std;
int smallestIndex(int array[],int s);
int main()
{
int array[20];
int i,n,s_index;
cout<<"Enter size of array:"<<endl;
cin>>n;
cout<<"Enter elements: ";
for(i=0;i<n;i++)
cin>>array[i];
s_index=smallestIndex(array, n);
cout<<"Smallest element "<<array[s_index]<<" at index: "<<s_index<<endl;
system("pause");
}
int smallestIndex(int array[],int size)
{
int i,s_loc=0;
int min=array[0];
for(i=0;i<size;i++)
{
if(array[i]<min)
{
min=array[i];
s_loc=i;
}
}return s_loc;
}