Given: an int variable k, an int array currentMembers that has been declared and initialized, an int variable nMembers that contains the number of elements in the array, an int variable memberID that has been initialized, and a bool variable isAMember,

Given: an int variable k, an int array currentMembers that has been declared and initialized, an int variable nMembers that contains the number of elements in the array, an int variable memberID that has been initialized, and a bool variable isAMember,

LANGUAGE: C++

CHALLENGE:

Given:

an int variable k,

an int array currentMembers that has been declared and initialized,

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

an int variable memberID that has been initialized, and

a bool variable isAMember,

SOLUTION:


isAMember=false;
for (k=0; k<nMembers; k++)
    if (currentMembers[k] == memberID){
        isAMember=true;
        break;
    }

Add comment