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
Before you ever buy your first stock or bond, it's important to understand what type of investor you are. This depends on a numb
Oksi-84 [34.3K]

Answer:

Moderate investor

Explanation:

The moderate investors are most popularly known as 'Balanced investors'. They accepts the risk to principal and they adopt the balanced approach. They mainly uses a mixture of bonds and stocks.

They values the reducing risks and then enhancing the returns equally. They accepts modest risks so as to ensure higher long term returns.

6 0
2 years ago
What describes Accenture's approach to automation?
Mrrafil [7]
<h2>Answer:</h2>

<h2>intelligence - centered</h2>

<h2>Explanation:</h2>

I hope it helps you

4 0
1 year ago
This is gonna be very long but I have no idea what to do, I'm confused.
kaheart [24]

for such experiment, you do it with care and to acquire and determine to put experience in it

Explanation:

because without you been or using experience the experiment will not correct

8 0
2 years ago
FREEFREEFREEFREEFREEFREE
Brrunno [24]

Answer:

niceeee :0

Explanation:

5 0
3 years ago
Read 2 more answers
Susan is working with an IT company. She has been asked to make sure that all of the functions in the company are in place and p
MrMuchimi

According to Henri Fayol, it can be said that there are five functions of management: planning, organizing, staffing, directing, and controlling. From the description in the question, it seems that Susan should employ the controlling management function – which is defined as ensuring that all the ongoing process are proceeding as planned.

It is clear that this definition is precisely what Susan needs to do to fulfill the request that she was given.

7 0
3 years ago
Other questions:
  • Write a program that requests a state abbreviation as input and displays the justices appointed from that state. The justices sh
    6·1 answer
  • What are the key goal, performance, and risk indicators?
    15·1 answer
  • An adiabatic capillary tube is used in some refrigeration systems to drop the pressure of the refrigerant from the condenser lev
    15·1 answer
  • IT specialists must display technical expertise and collaborative proficiency in the workplace. Select the IT specialist who dem
    7·1 answer
  • Write a technical term for following statements
    15·1 answer
  • Lab 6B: printing a binary number
    13·1 answer
  • The goal of a system is to
    6·1 answer
  • You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e
    14·1 answer
  • Davingould1115...................answer 3​
    11·1 answer
  • What is the meaning of FTTH
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!