answer.
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]
2 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]2 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
Write pseudocode for a program which will ask a user to enter two numbers a and b. It then asks what operation is to be performe
sleet_krkn [62]

get int input for a

get int input for b

get string input for operator

if a is not int or b is not int throw exception and print error

if operator is not * / // or % throw exception and print error

if operator is * do multiplication of a and b and make answer c

else if operator is / do division of a and b and make answer c

else if operator is // do floor division of a and b and make answer c

else if operator is % do floor modulo of a and b and make answer c

print c

5 0
2 years ago
What does NOT match with Agile Manifesto?
Butoxors [25]

Answer:

yes

Explanation:

7 0
1 year ago
A blood bank maintains two tables - DONOR, with information about people who are willing to donate blood and ACCEPTOR, with info
Kipish [7]

Answer:

The sql query is given below.

Since we need to count of males and females for a particular blood group, we put xxx for the blood group.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors,

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

Explanation:

The clauses in the query are as follows.

1. SELECT: all the columns required in the output are put in this clause.

2. FROM JOIN ON: the table(s) from which the above columns are taken are put in this clause.

3. WHERE: any condition required to filter the output is put in this clause.

The query is explained below.

1. Find the number of male donors. Number of anything can be found using COUNT() function. A query is required since gender is included in deciding the type of donor.

2. The query is defined to find number of male donors as follows.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "M%"; )

3. In the previous query, LIKE operator is used since it is not defined what value is stored for male donors.

4. Similarly, the query to find the number of female donors is formed.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "F%"; )

5. Next, the final query is formed as follows.

SELECT: both COUNT() functions will come here.

FROM: table name

WHERE: specific blood group will be put here

GROUP BY: this clause is optional and is not used in this query.

HAVING: this clause is optional and is not used in this query.

6. The query after putting all clauses is shown below.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%"),

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%")

FROM DONOR

WHERE BG = xxx;

7. Alias is used in the above query for each column to get the final query.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors, COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

7 0
1 year ago
What happens it the offshore team members are not able to participate in the iteration demo due to time zone/infrastructure issu
professor190 [17]

The best option that will suite is that there will be no major issues since the offshore leads and the onsite members participated in the demo with the Product Owner/Stakeholders they can cascade the feedback to the offshore members

Explanation:

Iteration demo is the review which is done to gather the immediate feedback from the stakeholders on a regular basis from the regular cadence. This demo will be one mainly to review the progress of the team and the and to cascade and show their working process

They show their working process to the owners and they and the other stakeholders and they get their review from them and so there will be no issues if the members are not able to participate

5 0
2 years ago
What does Josh Silverman name as the most important aspect of managing finances?
Andre45 [30]

The answer is a the first one

6 0
1 year ago
Read 2 more answers
Other questions:
  • List at least six things you would check for if you were asked to evaluate the workspace of an employee for ergonomics
    10·1 answer
  • Rupa would like to quickly insert a table into her document without having to worry about formatting the data in the table. Whic
    5·2 answers
  • Remember that ""state space"" refers to the space of all potential possibilities. Which dichotomous questions below will success
    5·1 answer
  • Write a program to determine all pairs of positive integers, (a, b), such that a &lt; b &lt; 1000 and [a2 + b2 + 1)/(ab) is an i
    13·1 answer
  • 14.28. Consider the relation R, which has attributes that hold schedules of courses and sections at a university; R = {Course_no
    7·1 answer
  • As part of the duties of a digital forensics examiner, creating an investigation plan is a standard practice. Write a 3 to 4 (no
    9·1 answer
  • 1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
    10·1 answer
  • Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
    15·1 answer
  • When using the Python shell and code block, what triggers the interpreter to begin evaluating a block of code
    14·1 answer
  • There are two cons to an OLTP database. Which of the following are a solution of these cons?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!