1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ANTONII [103]
4 years ago
11

Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has

been initialized, and a boolean variable isAMember. Write code that assigns true to isAMember if the value of memberID can be found in current Members, and that assigns false to isAMember otherwise. Use only k, currentMembers, memberID, and isAMember.
Computers and Technology
1 answer:
Alekssandra [29.7K]4 years ago
4 0

Answer:

The c++ program is given below. Nothing is displayed as per the question.

#include <iostream>

using namespace std;

int main() {    

   // declaration and initialization of integer variables

   int k, memberID = 12, nMembers=5;

   bool isAMember;    

   // declaration and initialization of integer array

   int currentMembers[] = {12, 34, 56, 78, 90};    

   for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           // when member is found in the array, the loop is exited using break

           isAMember = true;

           break;

       }

       else

           isAMember = false;

   }    

   return 0;

}

Explanation:

The program begins with declaration and initialization of integer variables and followed by initialization of the array holding the id of all the members.

The Boolean variable is declared but not initialized.

int k, memberID = 12, nMembers=5;

bool isAMember;

int currentMembers[] = {12, 34, 56, 78, 90};

After this, the array holding the id of the members is searched for the given member id. This is done using  a for loop and a if else statement inside the loop.

If the member id is present in the array, the variable isAMember is initialized to true otherwise it is assigned false.

When the variable isAMember is initialized to true, the break statement is used to exit from the loop.

for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           isAMember = true;

           break;

       }

       else

           isAMember = false;

 }

The break is used since other values of id in the array will not match the given member id and the variable, isAMember will be initialized to false even if the given member id is present in the array. Hence, it is mandatory to exit the loop once the given member id is found in the array.

This program can be tested for different values of the id of the members and different sizes of the array.

You might be interested in
Look at the picture lol
andrey2020 [161]

Answer:

Zoom in more please and than i can help

Explanation:

6 0
3 years ago
Read 2 more answers
What is responsible for making an axle spin in an electric motor? an outside power source attached to a magnet an outside power
Mashutka [201]

the correct answer is c

6 0
3 years ago
Read 2 more answers
In what year was the first world-wide web software created by tim berners-lee?
Elena L [17]
1989 <span>A graduate of Oxford University, Tim Berners-Lee invented the Web while at CERN, the European Particle Physics Laboratory, in </span>1989<span>. He wrote the first web client and server in </span>1990<span>.</span>
6 0
3 years ago
WILL GIVE BRAINLIEST TO THE FIRST CORRECT ANSWER!!!!
ad-work [718]

Answer:

It remove all the format on a block of selected text, or a paragraph, or the whole text. The formatting such as font, size, text attributes (bold/italic) and color you applied in the text can be cleared with one click, and then the text will return to its default style.

7 0
3 years ago
1. What is the global marketplace?
podryga [215]

.......................................

4 0
3 years ago
Read 2 more answers
Other questions:
  • What type of document is a mobile device's EULA?
    13·1 answer
  • Adding a ____ to text adds depth and helps the letters display prominently.
    5·1 answer
  • What is the theory of trouble shooting
    10·2 answers
  • (15) What is the best definition of a contextual tab?
    8·1 answer
  • WILL GIVE BRAINLIEST!!!!!!!
    14·1 answer
  • How would you open the web browser in Linux and still have access to the Linux terminal?
    14·1 answer
  • Help please! <br>Will give brainliest! ​
    8·1 answer
  • What's a big question or problem in the tech field you'd like to solve and why?
    6·1 answer
  • A technician wants to replace a failing power supply on a high-end gaming computer. which form factor should the technician be l
    5·1 answer
  • Live footage refers to:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!