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
How many arguments are required for the sum function?
podryga [215]
Provide us with this "sum" function, and we can tell you. We aren't psychic.
7 0
3 years ago
Tinh T = a1*a2*a3*...an<br><br> Giúp em với
Studentka2010 [4]

Answer:

??????

Explanation:

??????? okay okay

3 0
2 years ago
Which of the following best describes the purpose of a design specification?
snow_lady [41]

Answer:

it is.    Describing the requirements for how a program will work or users will interact with it

Explanation:

mark brainlist

6 0
2 years ago
Read 2 more answers
Which of the following refers to special eyeglasses from Google that provide the user with visual information directly in front
maks197457 [2]

Answer:

(E) Glass

Explanation:

  • Google Glass is the Smart Glasses Device from Google.
  • It has very high advanced technical specifications.
  • It is a wearable device that provide all the information at your eyes.
  • The features include voice assistance, glanceable and wireless enabled device.
  • Option (A) Fitbit is a company which has products like Smart Watches, Fitness Trackers and other accessories.
  • Option (B) Flex is not a eye glasses product from Google, it is an electronics company.
  • Option (C) Roku is not a eye glasses product from Google, it is Smart TV appliances and Streaming Players company.
  • Option (D) Nook is not a eye glasses product from Google, it is Tablet from the company Barnes & Noble.
  • So, option (E) Glass is correct option and the rest are all wrong options.

5 0
3 years ago
Alexis plans to stop trading once she lose 5% of her account balance, her account balance is $215.00. How much money is she will
irina1246 [14]

Answer:

She's willing to lose $10.75.

Explanation:

$215.00 * .05 = answer

         or

$215.00 * .95 = x

$215.00 - x = answer

7 0
2 years ago
Other questions:
  • ___ is the branch of computer science that explores techniques for incorporating aspects of intelligence into computer systems.
    5·1 answer
  • Survey Q. Non-scoring: What role is played in the team? (1 correct answer)
    14·1 answer
  • To what would you compare the transport layer?
    14·1 answer
  • Question 2 (2 points)
    6·1 answer
  • 5. Which one of the following statements is true for spell checkers? A. Most spell checkers flag inappropriate word usage. B. A
    5·1 answer
  • Which screen should be open to customize or personalize a desktop background?
    15·2 answers
  • One way to initiate a file download from a web page is to
    8·1 answer
  • What is another name for a numbered list
    6·1 answer
  • What is the output for this program?
    12·1 answer
  • What technology would a bank's website use a scramble information as it is transmitted over the Internet
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!