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]
4 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]4 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
Wobble extensions allows the socket to pivot.<br> O True<br> O False
Agata [3.3K]
True

(I’m not sure if that’s right a picture below may help with the answer too)

4 0
3 years ago
In the ______ phase of the organizational life cycle, the organization is usually very small and agile, focusing on new products
Vlad [161]

Answer:

Entrepreneurship

Explanation:

Different phases of  organizational life cycles can be observed depending on the stage of the company. These cycles are,

  • Entrepreneurship
  • Survival and Early Success
  • Sustained Success
  • Renewal (or Decline)

In the initial stage which is  Entrepreneurship Phase,  all of the founders take part in various activities, no formality is formed between founders and employees. Generally lots of ideas are present and company is actively searching to define correct market and products to focus on.

5 0
3 years ago
About ceramics: Generally are hard and brittle. a) True b)-False
aniked [119]

Answer:

true

Explanation:

8 0
3 years ago
PWM input and output signals are often converted to analog voltage signals using low-pass filters. Design and simulate the follo
Temka [501]

Answer:

Attached below

Explanation:

PWM signal source has 1 KHz base frequency

Analog filter : with time constant = 0.01 s

low pass transfer function = \frac{1}{0.01s + 1 }

PWM duty cycle is a constant block

Attached below is the design and simulation into Simulink at 25% , 50% and 100% respectively

5 0
3 years ago
If a resistor only has three color bands, it has a tolerance of 20 percent. What would this mean for a resistor specified at 10,
Norma-Jean [14]
B is the correct answe it will fail if more than 12.000
Hope this helps
:)
3 0
3 years ago
Other questions:
  • A 3-kg block rests on top of a 2-kg block supported by, but not attached to, a spring of constant 40 N/m. The upper block is sud
    14·2 answers
  • Steam at 150 bars and 600°C passes through process equipment and emerges at 100 bars and 700°C. There is no flow of work into or
    8·1 answer
  • A concentric tube heat exchanger for cooling lubricating oil is comprised of a thin-walled inner tube of 25 mm diameter carrying
    13·1 answer
  • If the specific surface energy for magnesium oxide is 1.0 J/m2 and its modulus of elasticity is (225 GPa), compute the critical
    7·1 answer
  • Given a two-dimensional steady inviscid air flow field with no body forces described by the velocity field given below. Assuming
    8·1 answer
  • Consider the gas carburizing of a gear of 1018 steel (0.18 wt %) at 927°C (1700°F). Calculate the time necessary to increase the
    12·1 answer
  • To measure the effective coefficient of friction in a bone joint, a healthy joint (and its immediate surroundings) can be remove
    14·1 answer
  • If the two 304-stainless-steel carriage bolts of the clamp each have a diameter of 10 mmmm, and they hold the cylinder snug with
    11·1 answer
  • Solve using Matlab the problems:
    12·1 answer
  • Technician A says that collapsible steering columns may use a pyrotechnic charge. Technician B says that collapsible brake pedal
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!