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
egoroff_w [7]
3 years ago
12

Given :an int variable k,an int array currentMembers that has been declared and initialized ,an int variable nMembers that conta

ins the number of elements in the array ,an int variable memberID that has been initialized , andan int variable isAMember, write code that assigns 1 to isAMember if the value of memberID can be found in currentMembers, and that assigns 0 to isAMember otherwise. Use only k, currentMembers, nMembers, and isAMember.
Computers and Technology
1 answer:
ipn [44]3 years ago
5 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, 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 = 1;

           break;

       }

       else

           isAMember = 0;

   }

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.

int k, memberID = 12, nMembers=5, 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 1 otherwise it is assigned 0.

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

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

   {

       if(memberID == currentMembers[k])

       {

           isAMember = 1;

           break;

       }

       else

           isAMember = 0;

 }

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 assigned value 0 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.

Also, the value of the variable isAMember is not displayed since it is not mentioned in the question.

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
Rectangular box formed when each column meet​
Over [174]

Answer:

If this is a true or false I guess my answer is true?

Explanation:

3 0
3 years ago
Complete the following sentences using each of the words provided ONCE only. KEYBOARD DESKTOP STORE PRINTER COMPUTER MOUSE MONIT
WARRIOR [948]

Answer:

Explanation:

Monitor is an electronic device that retrieves, and processes shows you what is going on in the computer.

Desktop is the first image you see on your screen when the computer is is used for telling the computer what to do.

keyboard

is used for typing documents. Printer is used for putting documents on paper. CD Bay you can insert a CD or Compact Disc. is is box inside and shaped

8 0
1 year ago
4. You are planning to buy a new couch for your family room. Before you leave for the furniture store, you measure the available
zysi [14]
First, convert feet to inches. The ' denotes foot measurement while the " denotes inches. Since there are 12 inches in a foot,

5'10" = (5*12) + 10 = 70 inches
6'8" = (6*12) + 8 = 80 inches

a.) The lower limit is 70 inches while the upper limit is 80 inches.
b.) First, divide 78 inches by 12. That would 6.5 or 6 and a half feet. Since half foot is 6 inches, the length of the couch is 6'-6"
c.) Since the couch is between the limits, yes it would fit the space.

7 0
3 years ago
Would an artificial intelligence come into existence anytime in the next 30 years?
Scrat [10]
Artificial Intelligence, based on neural networks, is available now.
4 0
3 years ago
2. A data catalog identifies all of the following, except: a. Attribute data type b. Attribute range of values c. Attribute cons
alexandr1967 [171]

Answer:

c. Attribute constraints

Explanation:

A data catalog identifies all of the following, except: "Attribute constraints"

The above statement is TRUE because a Data Catalog, a metadata management service, operates by searching for key data, understand and manage data for usefulness.

Data Catalog checks on the BigQuery datasets, tables, and views and checks both technical and business metadata by identifying the following attributes:

1. Data type

2. Range of values

3. Value for Instructor ID

5 0
3 years ago
Other questions:
  • One type of technology that can verify a person's identity is _____.
    6·2 answers
  • Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
    5·1 answer
  • According to COSO, which of the following components addresses the need to respond in an organized manner to significant changes
    14·1 answer
  • All of the following are challenges presented by changing technology as it relates to the special events field EXCEPT: A. the ab
    13·1 answer
  • If you define a destructor, are you required to define an operator '=' and a copy constructor?
    9·1 answer
  • Multiple arrays. Jump to level 1 For any element in keysList with a value greater than 40, print the corresponding value in item
    7·2 answers
  • Given the following structure and variable definitions, struct customer { char lastName[ 15 ]; char firstName[ 15 ]; unsigned in
    6·1 answer
  • To check if your operating system is up to date, click Start then click Control Panel and choose _______________. Select one: a.
    11·1 answer
  • Calculate The Average of Grades Instructions:
    8·1 answer
  • In C++ please (read the image below for instructions)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!