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
Water is the working fluid in a Rankine cycle. Superheated vapor enters the turbine at 8 MPa, 560°C and the turbine exit pressur
hoa [83]

Answer:

1. The net power developed=9370.773KW

2. Thermal Efficiency= 0.058

Explanation

Check attachment

5 0
3 years ago
Balanced forces will result in which of the following
tia_tia [17]
D is the answer. Hope this helped
8 0
3 years ago
Calculate and plot the radial and circumferential stress distribution in the left ventricle at the end of systole (p 5 80 mmHg;
alexandr402 [8]

Answer:

62990.08 N/M

Explanation:

Circumferential stress, or hoop stress, a normal stress in the tangential (azimuth) direction. axial stress, a normal stress parallel to the axis of cylindrical symmetry. radial stress, a stress in directions coplanar with but perpendicular to the symmetry axis.

See attachment for the step by step solution of the given problem..

8 0
3 years ago
Which type of irrigation conserves more water than other types of irrigation?
vlada-n [284]
Drip irrigation

Drip irrigation is one of the most efficient types of irrigation systems. The efficiency of applied and lost water as well as meeting the crop water need ranges from 80% to 90%
6 0
3 years ago
Which claim does president Kennedy make in speech university rice ?
mafiozo [28]

Answer:  The United States must lead the space race to prevent future wars.

Explanation: Hope this helps

4 0
2 years ago
Read 2 more answers
Other questions:
  • Nc3
    12·1 answer
  • A tire-pressure monitoring system warns you with a dashboard alert when one of your car tires is significantly under-inflated.
    6·1 answer
  • What is the solution to the system of equations?<br><br>2x-y=7<br>y=2x+3​
    8·1 answer
  • Someone claims that the shear stress at the center of a circular pipe during fully developed laminar flow is zero. Do you agree
    12·1 answer
  • A truck is hauling a 300-kg log out of a ditch using a winch attached to the back of the truck. Knowing the winch applies a cons
    14·1 answer
  • Which of the following is an example of a reliable source?
    10·1 answer
  • The themes around which social sciences texts are organized boost understanding by
    11·1 answer
  • What is the difference between a Datum and a Datum Feature? a) A Datum and Datum Feature are synonymous. b) A Datum is theoretic
    14·1 answer
  • A long bone is subjected to a torsion test. Assume that the inner diameter is 0.375 in. and the outer diameter is 1.25 in., both
    14·1 answer
  • - If you overload the rear portion of you vehicle &amp; it's raining out, your car could easily:
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!