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
A gas refrigeration system using air as the working fluid has a pressure ratio of 5. Air enters the compressor at 0°C. The high-
zimovet [89]

Answer:

(a) Effectiveness of the regenerator= 0.433

(b) The rate of heat removal=21.38 kW

Explanation:

The solution and complete explanation for the above question and mentioned conditions is given below in the attached document.i hope my explanation will help you in understanding this particular question.

5 0
3 years ago
Two stepped bar is supported at both ends.At the join point of two segments,the force F is applied(downwards).Calculate reactive
nlexa [21]

Answer:

F=200kN

Explanation:

8 0
3 years ago
7. An energy auditor is part of what career field?
Rashid [163]
An energy auditor is part of power operations
6 0
2 years ago
What is the critical path and time duration?
kvasek [131]

The critical path is A-B-C, with a duration of 15 minutes.

<u>Explanation</u>:

  • The critical path is A-B-C, with a term of 15 minutes. You don't need to be knowledgeable in computer lingo to make sense of this one (as I made sense of it absent a lot of data on that half of the condition). Here's the manner by which I made sense of this.  
  • The main thing I saw was that "predecessor" was utilized, which implies something precedes the other thing. That provided me the primary insight that A precedes B and C, and that B must precede C. Then, I just included the term times for the three ways, which allowed me 15 minutes.
3 0
3 years ago
Software piracy occurs when
mario62 [17]

Answer:

Someone steals software

3 0
3 years ago
Other questions:
  • An open 1- -m-diameter tank contains water at a depth of 0.7 m when at rest. As the tank is rotated about its vertical axis the
    5·2 answers
  • A solid titanium alloy [G 114 GPa] shaft that is 720 mm long will be subjected to a pure torque of T 155 N m. Determine the mini
    5·1 answer
  • An ideal Carnot engine extracts of heat from a high-temperature reservoir at 1200 during each cycle, and rejects heat to a low-t
    10·1 answer
  • The linkage is made of three pin-connected A992 steel members, each having a diameter of 114 in. A three-member system. Pin supp
    6·1 answer
  • Consider a single crystal of some hypothetical metal that has the FCC crystal structure and is oriented such that a tensile stre
    7·1 answer
  • 7–2 Cooling of a Hot Block by Forced Air at High
    6·1 answer
  • Ký hiệu của vật liệu cơ khí
    15·1 answer
  • On some engines after torquing cylinder head fasteners you must
    12·1 answer
  • What are the causes and solutions of social problems ?what are the causes and solutions of social problems ​
    15·1 answer
  • Please help me with this question
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!