Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes,

Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes,

LANGUAGE: C++

CHALLENGE:

Given

an int variable k,

an int array incompletes that has been declared and initialized,

an int variable nIncompletes that contains the number of elements in the array,

an int variable studentID that has been initialized, and

an int variable numberOfIncompletes,

SOLUTION:


numberOfIncompletes=0;
for (k=0; k<nIncompletes; k++){
    if (incompletes[k] == studentID){
        numberOfIncompletes++;
    }
}

Add comment