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
13) What are the benefits and detriments of each of the following? Consider both the systems and the programmers’ levels. a. Sym
dsp73

Answer:

Automatic and Explicit Buffering.

In the case of explicit buffering, the length of the queue is provided while in automatic buffering the queue size needs to be indefinite. In automatic buffering there is no need to block the sender while coping the message. While in explicit buffering the sender is blocked for the space in queue.

No memory is being wasted in explicit buffering.

Send by Copy and Send by Reference.

By using the send by copy method, the receiver is not able to change the state of parameter while send by reference allow. The advantage of using the send by reference method is that it allows to change a centralized application to its distributed version.

Fixed-sized and Variable-sized Messages.

In fixed size messaging refers, the buffer size is fixed. This means only a particular number of messages can only be supported by the fixed size buffer. The drawback of the fixed size messages is that they must be a part of fixed size buffer. These are not a part of variable size buffer. The advantage of variable size message is that the length of the message is variable means not fixed. The buffer length is unknown. The shared memory is being used by the variable size messages.

Explanation:

5 0
3 years ago
What should you do when you are working on an unclassified system and receive an email.
koban [17]

Answer:

Don't respond to it. Either leave it there, or just delete it. It is most likely spam or a scammer trying to get your information. Don't respond, please.

3 0
2 years ago
Question 1
weeeeeb [17]

Answer:

-6.4

Explanation:

just divide -32 by 5 and you will get your answer of -6.4

7 0
3 years ago
Write a program that prompts the user for a word or phrase, and determines if the entry is a palindrome. A palindrome is a word
vekshin1

Answer:

Explanation:

The following code is written in Python. It asks the user for an input. Then cleans the input using regex to remove all commas, whitespace, and apostrophes as well as making it all lowercase. Then it reverses the phrase and saves it to a variable called reverse. Finally, it compares the two versions of the phrase, if they are equal it prints out that it is a palindrome, otherwise it prints that it is not a palindrome. The test case output can be seen in the attached picture below.

import re

phrase = input("Enter word or phrase: ")

phrase = re.sub("[,'\s]", '', phrase).lower()

reverse = phrase[::-1]

if phrase == reverse:

   print("This word/phrase is a palindrome")

else:

   print("This word/phrase is NOT a palindrome")

7 0
2 years ago
Brandon has configured one of the applications hosted on his cloud service provider to increase the number of resources as neede
goldenfox [79]

Answer:

The description of this capability is:

d. Horizontal scaling

Explanation:

The capability that Brandon has achieved is horizontal scaling, which involves the increasing of the resources of cloud applications to meet his increasing demand for cloud services.  Vertical scaling involves the addition or subtraction of power to a cloud server, which practically upgrades the memory, storage, or processing power.  But to scale horizontally, more resources are added or subtracted.  The purpose of horizontal scaling is to spread out or in the workload of existing resources and either increase or decrease overall performance and capacity.

8 0
3 years ago
Other questions:
  • Describe an application where a parallel circuit might work better than a series circuit
    15·2 answers
  • Where should you look to find contact information about a company? I. on the company website II. at your local library III. in t
    11·2 answers
  • Do Violent Video Games Make People More violent in Real Life ?
    14·1 answer
  • How did tafts accomplishments regarding conservation and trust-busting compare to roosevelt?
    11·1 answer
  • 1.Which type of camera tool pushes the picture back and makes it wider, exaggerating the distance between the background and for
    13·2 answers
  • You should structure the<br> first before you search for a relevant picture.
    11·1 answer
  • ________________ occur when a system produces incorrect, inconsistent, or duplicate data.
    6·2 answers
  • In a five-choice multiple-choice test, which letter is most often the correct
    10·2 answers
  • BADM-Provide a reflection of at least 500 words (or 2 pages double spaced) of how the knowledge, skills, or theories of this cou
    7·1 answer
  • Some hackers are skillful computer operators, but others are younger inexperienced people who experienced hackers refer to as?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!