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
Which of the following is not caused by alcohol?
Brrunno [24]

Answer:

Inhibited comprehension

4 0
2 years ago
Read 2 more answers
Which of the following correctly describes caster?
sertanlavr [38]
Lil durk 4000
Example

3 0
3 years ago
1. A turbine in a steam power plant operates isentropically with an inlet pressure (P3) of 3.5 MPa and inlet temperature (T3) of
sergey [27]

Answer:

See attached picture.

Explanation:

See attached picture for explanation.

4 0
3 years ago
A rigid tank contains an ideal gas at 40°C that is being stirred by a paddle wheel. The paddle wheel does 240 kJ of work on the
Sergeu [11.5K]

To solve the problem it is necessary to consider the concepts and formulas related to the change of ideal gas entropy.

By definition the entropy change would be defined as

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{P_2}{P_1})

Using the Boyle equation we have

\Delta S = C_p ln(\frac{T_2}{T_1})-Rln(\frac{v_1T_2}{v_2T_1})

Where,

C_p = Specific heat at constant pressure

T_1= Initial temperature of gas

T_2= Final temprature of gas

R = Universal gas constant

v_1= Initial specific Volume of gas

v_2= Final specific volume of gas

According to the statement, it is an isothermal process and the tank is therefore rigid

T_1 = T_2, v_2=v_1

The equation would turn out as

\Delta S = C_p ln1-ln1

<em>Therefore the entropy change of the ideal gas is 0</em>

Into the surroundings we have that

\Delta S = \frac{Q}{T}

Where,

Q = Heat Exchange

T = Temperature in the surrounding

Replacing with our values we have that

\Delta S = \frac{230kJ}{(30+273)K}

\Delta S = 0.76 kJ/K

<em>Therefore the increase of entropy into the surroundings is 0.76kJ/K</em>

8 0
3 years ago
If you are a government authority what extend will you modify the existing policy
mr_godi [17]

Answer:

kk

Explanation:

dkdndidodd ndidkjeeiwonejeeidmdnddkdidfmndd

4 0
3 years ago
Other questions:
  • 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
  • CNG is a readily available alternative to
    5·1 answer
  • The annual storage in Broad River watershed is 0 cm/y. Annual precipitation is 100 cm/y and evapotranspiration is 50 cm/y. The s
    10·2 answers
  • Determine the design angle ϕ (0∘≤ϕ≤90 ∘) between struts AB and AC so that the 400 lb horizontal force has a component of 600 lb
    10·1 answer
  • What is the normal balance side of an asset?
    9·1 answer
  • What is the answer???
    10·1 answer
  • Which state did NOT have people that got sick from the
    10·1 answer
  • When you accelerate, the size of the front tire patch becomes____
    15·1 answer
  • Using your knowledge of how an ATM is used, develop a set of use cases that could serve as a basis for understanding the require
    15·1 answer
  • An American architect whose principles of building included consonance with the landscape was ____________________________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!