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]
3 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]3 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
When an IPv6 device with no pre-configured IPv6 address powers up, it can calculate a global 128-bit IPv6 address for itself usi
RSB [31]

Answer:

True

Explanation:

IPv6 Is a later version of IP addresses, used to solve the problem of the limited number of IPv4 addresses in the network.

Just like IPv4, IPv6 can also is configured to a device statically and dynamically. Dynamic IPv6 configuration could be a stateless autoconfiguration SLAAC, a stateless DHCPV6 or a stateful DHCPV6.

The IPv6 address is configured with a prefix and a prefix length and a EUI generated 64 bit interface or a random interface id by the device.

8 0
3 years ago
Anyone have Minecraft dungeons I need help with it
steposvetlana [31]

Answer:

for sure add me upppp its mypplong

5 0
3 years ago
Read 2 more answers
Many people describes computers as complex machine. what can this mean?
Airida [17]
They work in many different ways?
8 0
3 years ago
Widget Corp. wants to shift its list of inventory to a cloud so that its different branches can access it easily. The company ne
____ [38]

Answer:

The best cloud option for Widget Corp considering the cloud computing option should be cost-effective and should not expose mission-critical applications and data to the outside world.

Is a hybrid could.

Explanation:

The reasons behind this answer are that in the first place the cloud is not going to be fully managed by a third party, but also by the IT department of Widget Corp allowing it to control its security. Also, that the cloud can be adapted to public or mainstream sources, resources, and platforms. Making it very user friendly and lowering down specific knowledge to use it.

5 0
3 years ago
State<br> any three (3) reasons why users attach speakers to their computer?
lidiya [134]

Answer:

To complete the computer setup, to hear audio, to share audio.

Explanation:

A computer is not <u>really</u> complete without speakers.

So that you can actually hear the computer's audio.

So that you can have multiple people hear the same audio. (Headphones do not do this)

4 0
2 years ago
Other questions:
  • In Java
    6·1 answer
  • The "Rudolph Rule" is best described by which of the following?
    9·1 answer
  • A method a. may have zero or more parameters b. never has parameter variables c. must have at least two parameter variables d. m
    10·1 answer
  • What are two names for the database that holds digital signatures provided by os manufacturers, such as microsoft and red hat?
    6·1 answer
  • What advantages do teams have for solving problems
    14·1 answer
  • Private sharing model on Opportunities. Leadership has asked the Administrator to create a new custom object that will track cus
    7·1 answer
  • Join zoom meet <br>id=547 458 9345<br>pw=sencHURI​
    8·2 answers
  • Anyone on ps4 willing to trade me a fennec or McClaren on rocket league?
    6·2 answers
  • The full meaning of UNIVAC and ENIAC​
    5·2 answers
  • Write a format operation that builds a string for the float variable amount that
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!