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
What is the major drawback to use whiskers as a dispersed agents in composites? a)- High price b)- Large length to diameter rati
artcher [175]

Answer: C) a&c

Explanation: Composite materials are the materials which are made up of the two or more material of different properties.They are usually having properties like high hardness,low in density,no dissolving into each other etc. Whiskers as a dispersing agent in composite materials are usually not preferred because they are expensive as well as they are not easy to disperse in the composite material.Thus option (c) is the correct answer.

7 0
4 years ago
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
Zarrin [17]

Answer:

  83.6%

Explanation:

<h3>(a)</h3>

On its current schedule, the plant can theoretically produce ...

  (30 pc/h/machine)(10 machine)(8 h/shift)(2 shift/day)(5 day/wk)(50 wk/yr)

  = (30)(10)(8)(2)(5)(50) pc/yr = 1,200,000 pc/yr

__

<h3>(b)</h3>

On the proposed schedule, this production becomes ...

  (30 pc/mach)(10 mach)(8 h/sh)(3 sh/da)(6 da/wk)(51 wk/yr)

  = (30)(10)(8)(3)(6)(51) pc/yr = 2,203,200 pc/yr

The increase in capacity is ...

  (2,203,200/1,200,000 -1) × 100% = 83.6% . . . capacity increase

_____

<em>Additional comment</em>

The number of parts per shift did not change. Only the number of shifts per year changed. It went up by a factor of (3/2)(6/5)(51/50) = 1.836. Hence the 83.6% increase in capacity.

We have to assume that maintenance and repair are done as effectvely as before in the reduced down time that each machine has.

3 0
2 years ago
2. The unthreaded part of a bolt or screw is called the
aksik [14]

Answer:

The grip

Explanation:

the head of all headed bolt (except countersunk head bolt)

3 0
3 years ago
Read 2 more answers
2. When performing an alignment, what action should be taken immediately after putting a vehicle on the rack?
mash [69]
D...................
3 0
3 years ago
Convert 25 mm into in.
mihalych1998 [28]

Answer:

25 mm = 0.984252 inches

Explanation:

Millimeter and inches are both units of distance. The conversion of millimeter into inches is shown below:

<u>1 mm = 1/25.4 inches</u>

From the question, we have to convert 25 mm into inches

Thus,

<u>25 mm = (1/25.4)*25 inches</u>

So,

25 mm=\frac{25}{25.4} inches

Thus, solving we get:

<u>25 mm = 0.984252 inches</u>

4 0
4 years ago
Other questions:
  • At the end of a power distribution system, a certain feeder supplies three distribution transformer, each one supplying a group
    8·1 answer
  • Electrical pressure or “force”<br><br> A) current<br> B) resistance <br> C) voltage
    6·1 answer
  • Calculate the diffusion current density for the following carrier distributions. For electrons, use Dn = 35 cm2/s and for holes,
    6·1 answer
  • An airplane flies horizontally at 80 m/s. Its propeller delivers 1300 N of thrust (forward force) to overcome aerodynamic drag (
    15·1 answer
  • You are given a C program "q2.c" as below. This program is used to calculate the average word length for a sentence (a string in
    5·1 answer
  • Which excerpt from "The Chrysanthemums' best reveals that Elisa is proud of her
    6·1 answer
  • The pressure at the bottom of an 18 ft deep storage tank for gasoline is how much greater than at the top? Express your answer i
    15·1 answer
  • How does the Ivanpah Solar Plant make electricity?
    12·1 answer
  • Many vehicles have indicator lights telling you when your
    13·1 answer
  • Overconfidence in more male drivers, particularly those under 25 years old, results in them being involved in crashes.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!