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
Ms office suite comes with its own set of pictures in the​
goldfiish [28.3K]

Answer:

clipart ...........................

Explanation:

clipart is the correct answer for the above question.

6 0
2 years ago
Imagine you accidently mistype the URL for your bank and you are redirected to a fake website that collects your information. Wh
fgiga [73]

Answer:

Financial identity theft

Explanation:

Financial identity theft is a fraudulent act that involves accessing someone's personal information without their consent or approval for fraudulent financial gain.

A typical financial identity theft is someone stealing your credit card information such as pin, cvv, etc. to make other financial transactions without your knowledge.

7 0
3 years ago
Which statement about dialogues is NOT correct? Select one: A. Users should be able to control the direction of speed of dialogu
Gennadij [26K]

Answer:

Option B is not correct

Explanation:

Dialogues become problematic when they appear automatically because of high level incompatibility

3 0
2 years ago
1
g100num [7]
Have a look at the man page for printf:

man 3 printf
4 0
3 years ago
Read 2 more answers
List the seven basic internal components found in a computer tower
egoroff_w [7]
1. Motherboard (you plug all other components to it)
2. Processor (CPU)
3. Memory (RAM)
4. Graphics card
5. Sound card (sometimes integrated with motherboard)
6. Hard Disk Drive (HDD)
7. Power supply unit
6 0
3 years ago
Read 2 more answers
Other questions:
  • It is safe to use your bright headlights if there is a car ahead of you within 300 feet
    9·2 answers
  • Which word processing file that contains text and other
    13·2 answers
  • You are asked to design a system of FP numbers representation (with your own design choices), labeled Custom_FP_48, for which we
    8·1 answer
  • Which of the following is true of how the Internet has responded to the increasing number of devices now using the network?
    7·1 answer
  • Which statement reflects an opinion about technology? Select all that apply. Select one or more: a. It is easy to imagine that a
    5·1 answer
  • To speed up the display of graphics, a(n) ________ is integrated into some video cards. select one:
    12·1 answer
  • What is the alogarithm for solving the perimeter of a triangle
    11·1 answer
  • Create a variable in php to store your university information and parse using jQuery Ajax and print your name. The variable must
    12·1 answer
  • 18. WHICH MENU WOULD MOST LIKELY ALLOW YOU TO ADJUST YOUR LINE SPACING? *
    5·1 answer
  • Tạo biến
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!