Heres given instructions:
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 ,
Write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes .
You may use only k , incompletes , nIncompletes , studentID , and numberOfIncompletes .
Heres what I created and it says its wrong:
k=0;
numberOfIncompletes;
while (k < nIncompletes && !numberOfIncompletes)
{
if(incompletes[k] == studentID)
numberOfIncompletes
k++;
}
If anyone notices errors as to why it might be incorrect comment please!
Hello there, "numberOfIncompletes" seems to be a bool type variable since you used ! infront of it in the while loop means that it checks if it's false. If you want to set it to true in this loop you shuld probably give it the value true.