Answer:
The code to this question can be given as:
Code:
int k; //declare integer variable k
//declared array and initialized array
int currentMembers[]={1,2,3,4,5,9,6,7};
//declared integer variable memberID.
int memberID=9;
//declared boolean variable isAMember
boolean isAMember;
isAMember=false;
//assign value
for (k=0; k<nMembers; k++)
//loop
if (currentMembers[k] == memberID) //check condition
{
isAMember=true;
//change value to true.
break;
//break loop
}
Explanation:
In the above code firstly we declare the integer variables that name is already given in the question that is k and memberID in this variable we assign value. Then we declare an array variable currentMembers and initialized values in array. Then we declare a Boolean variable isAMember. This variable is used to assign only true or false value. Then we declare a for loop. loop is used to check all array elements.In this loop, we use the if condition in the if block if the array element matches with memberID. It breaks the condition and end of the loop.