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
adelina 88 [10]
3 years ago
15

You will create an array manipulation program that allows the user to do pretty much whatever they want to an array. When launch

ing the program, the user will pass in a file name that contains a set of value and an int that informs the program how many values are in the file (see example below) Check to see if the file could be opened. Exit the program if it was not opened, otherwise continue Create an array and fill it with the values from file Present the user with a menu, detect their choice, and provide them any needed follow up prompts that are needed. Continue until they want to quit

Engineering
1 answer:
enyata [817]3 years ago
3 0

Answer:

Check the explanation

Explanation:

#include <iostream>

using namespace std;

void insert(int* arr, int* size, int value, int position){

if(position<0 || position>=*size){

cout<<"position is greater than size of the array"<<endl;

return ;

}

*size = *size + 1 ;

for(int i=*size;i>position;i--){

arr[i] = arr[i-1];

}

arr[position] = value ;

}

void print(int arr[], int size){

for(int i=0;i<size;i++){

cout<< arr[i] <<" ";

}

cout<<" "<<endl;

}

void remove(int* arr, int* size, int position){

* size = * size - 1 ;

for(int i=position;i<*size;i++){

arr[i] = arr[i+1];

}

}

int count(int arr[], int size, int target){

int total = 0 ;

for(int i=0;i<size;i++){

if(arr[i] == target)

total += 1 ;

}

return total ;

}

int main()

{

int size;

cout<<"Enter the initial size of the array:";

cin>>size;

int arr[size],val;

cout<<"Enter the values to fill the array:"<<endl;

for(int i=0;i<size;i++){

cin>>val;

arr[i] = val ;

}

int choice = 5,value,position,target ;

do{

cout<<"Make a selection:"<<endl;

cout<<"1) Insert"<<endl;

cout<<"2) Remove"<<endl;

cout<<"3) Count"<<endl;

cout<<"4) Print"<<endl;

cout<<"5) Exit"<<endl;

cout<<"Choice:";

cin>>choice;

switch(choice){

case 1:

cout << "Enter the value:";

cin>>value;

cout << "Enter the position:";

cin>>position;

insert(arr,&size,value,position);

break;

case 2:

cout << "Enter the position:";

cin>>position;

remove(arr,&size,position);

break;

case 3:

cout<<"Enter the target value:";

cin>>target;

cout <<"The number of times "<<target<<" occured in your array is:" <<count(arr,size,target)<<endl;

break;

case 4:

print(arr,size);

break;

case 5:

cout <<"Thank you..."<<endl;

break;

default:

cout << "Invalid choice..."<<endl;

}

}while(choice!=5);

return 0;

}

Kindly check the attached images below for the code output.

You might be interested in
Explicar el funcionamiento de un multímetro analógico.
Whitepunk [10]

Answer:

Un multímetro analógico funciona como un medidor de bobina móvil de imán permanente (PMMC) para tomar mediciones eléctricas

Explanation:

El multímetro analógico es un medidor o galvanómetro D'Arsonval que funciona según el principio de los medidores de bobina móvil de imán permanente (PMMC)

Un multímetro analógico está formado por un puntero de aguja unido a una bobina móvil colocada entre el polo norte y sur de un imán permanente dispuesto de tal manera que, cuando una corriente eléctrica fluye a través de la bobina, genera una fuerza de campo magnético que interactúa con el imán fuerza de campo de los imanes permanentes que hace que la bobina se mueva junto con el puntero de la aguja sobre un dial graduado

Para controlar el movimiento del puntero de la aguja, de modo que el par requerido para producir una cantidad de movimiento por corriente detectada por el multímetro, se colocan dos resortes a través de la bobina para proporcionar resistencia al movimiento en ambas direcciones y para permitir la calibración del multímetro analógico.

4 0
3 years ago
Whats viruses c liver?
PtichkaEL [24]

Answer:

Hepatitis C is a viral infection that causes liver inflammation, sometimes leading to serious liver damage. The hepatitis C virus (HCV) spreads through contaminated blood.

5 0
2 years ago
Read 2 more answers
A long corridor has a single light bulb and two doors with light switch at each door.
Tpy6a [65]

Answer:

  Light = A xor B

Explanation:

If switches A and B produce True or False, then Light will be True for ...

  Light = A xor B

8 0
2 years ago
Air-conditioners consume a significant amount of electrical energy in buildings. Split air conditioner is a unitary system where
nydimaria [60]

Answer:

Evaporator,Compressor,Condensor ,Expanding valve

Explanation:

Split air conditioning :

  Split air conditioning means that, condensor unit or some time called outdoor unit is split from evaporator.It means that evaporator and condensor are placed at some distance.

The four component of split air conditioning system are as follows

1.Evaporator

 It absorb heat from room and produces the cooling effect.

2.Compressor

 It compresses the refrigerant which exits from evaporator.

3.Condensor

 It rejects the heat and cool the evaporator.

4.Expanding valve

  It allows to refrigerant to cool up to evaporator pressure.

6 0
3 years ago
True or False: The differential lock in an AWD-equipped vehicle can be used at any time.
Bingel [31]

the answer would be false

7 0
3 years ago
Read 2 more answers
Other questions:
  • A tire-pressure monitoring system warns you with a dashboard alert when one of your car tires is significantly under-inflated.
    6·1 answer
  • WILL MARK BRAINLEST PLEASE HELP
    10·1 answer
  • Refrigerant-134a enters a diffuser steadily as saturated vapor at 600 kPa with a velocity of 160 m/s, and it leaves at 700 kPa a
    10·2 answers
  • Yasir is trying to build an energy-efficient wall and deciding what materials to use. How can he calculate the thermal resistanc
    6·1 answer
  • The assembly consists of two blocks A and B, which have a mass of 20 kg and 30 kg, respectively. Determine the distance B must d
    14·2 answers
  • What is the maximum volume flow rate, in m^3/hr, of water at 15.6°C a 10-cm diameter pipe can carry such that the flow will be l
    9·1 answer
  • 4. Which of the following is the first thing you should do when attempting
    13·2 answers
  • ما جمع كلمة القوة؟help please
    10·1 answer
  • Steam enters an adiabatic turbine at 6 MPa, 600°C, and 80 m/s and leaves at 50 kPa, 100°C, and 140 m/s. If the power output of t
    14·1 answer
  • A 60-Hz 3-phase induction motor is required to drive a load at approximately 850 rpm. How many poles should the motor have
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!