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
Technician A says that the paper test could detect a burned valve. Technician B says that a grayish white stain on the engine co
Bumek [7]

Answer:

Both Technician A and B are correct.

Explanation: Both are correct, but keep note that different color coolants leave different color  stains.

6 0
3 years ago
Why is the lubrication system of an internal combustion engine equipped with an oil filter?
Ierofanga [76]

Answer:

to filter out any impurities such as metal shavings in the oil

6 0
3 years ago
What is a chipping hammer used for? <br><br> State three things.
aleksley [76]

Answer:

i hope this helps.

Explanation:

they are used for breaking concrete, can be positioned to break vertical and overhead surfaces, allows precisely chip away only specific areas.

7 0
3 years ago
Read 2 more answers
Oxygen combines with nitrogen in the air to form NOx at about
rusak2 [61]
B) Oxygen combines with nitrogen in the air to form NOx at about 2500 degrees Fahrenheit.
4 0
3 years ago
Read 2 more answers
A(n)<br> is a safety device commonly<br> used with a slotted nut.
liraira [26]

A safety device called a cotter pin. The cotter pin fits through a hole in the bolt or part. This keeps the nut from turning and possibly coming off.

5 0
3 years ago
Other questions:
  • A gear box’s shaft is made of a hollow circular steel tube with allowable yield stress equal to σa????????o???? . The shaft is l
    7·1 answer
  • If the electric field just outside a thin conducting sheet is equal to 1.5 N/C, determine the surface charge density on the cond
    9·1 answer
  • ITS FOR DRIVERS ED!!
    13·2 answers
  • (4 points) What field of work generally requires (a) an engineer to have a Professional Engineer
    11·1 answer
  • Global Convection Patterns include which of the following?
    12·1 answer
  • What is the name of the type of rocker arm stud that does not require a valve adjustment?
    12·1 answer
  • Workers who work with what kind of chemicals chemicals may require regular medical checkups on a more frequent basis as a result
    15·1 answer
  • A plant has ten machines and currently operates two 8-hr shift per day, 5 days per week, 50 weeks per year. the ten machines pro
    6·1 answer
  • Question is written in following attached screenshot.
    10·1 answer
  • The ______ number of a flow is defined as the ratio of the speed of flow to the speed of sound in the flowing fluid.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!