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
wo companies, Ajax Co. and Boho Inc., were negotiating a merger. In the course of the negotiations, an Ajax representative told
boyakko [2]

Answer:

Yes

Explanation:

If the Ajax representative fails to correct the previous statement this can cause misrepresentation.

4 0
3 years ago
Help please really fast!!
ra1l [238]

Answer:368 hdhtygtÿ

901 vuiøöńč

Explanation:

6 0
3 years ago
This is it dont anwser this is for my other account
Nezavi [6.7K]

Answer:

thanks for the poiunts

Explanation:

6 0
3 years ago
you have a permanent magnet whit remanent induction. than you cut a piec of that magnet. if you put that piece back into permane
ELEN [110]
Yes, it will. The induction will be the same as long as it’s put back together.
5 0
3 years ago
Mihuv8tr5qwertgyhjzxcvbnfr5y7nnbvcxzwertgyhujio vv solve the riddle
Inessa [10]

Answer:

v1QAZ3EDCRFV5TGB6YHNUJMIK,9OL0K9MIJNUHB7YGVTFCRDXESZWAq

Explanation:

qaAQzwsxedcnujmik,ol mkjuhtfcrxdZSWAQWSEDRFTGYHUJIKO,LP.; ,LMKJNUHTGDXESZWaEDRFTGHJKL,MNBVFDSWQAAWERTYUIOP;L,MNHGFDEWwertyuikolp;[l.,mnbvfre345678990098765434rtyhnbhju8765rtghjui875rfghji8765rfghju7654redfghu7643erfghji987yhjko987y

4 0
3 years ago
Read 2 more answers
Other questions:
  • The boy in the wagon begins throwing bricks out of the wagon to simulate rocket propulsion. The wagon begins at rest, and the bo
    12·1 answer
  • 100 points Im so bored lol
    11·2 answers
  • Give a reason why fighter aircraft use mid-wing design.
    11·1 answer
  • What are the basic parts of a radio system
    15·1 answer
  • Module 42 Review and Assessment
    7·1 answer
  • What structure was created to help prevent shipwrecks?
    9·1 answer
  • The size of an engine is called the engine
    13·2 answers
  • How might an operations manager alter operations to meet customer demand? Name at least two ways.
    7·1 answer
  • Which of the following is a possible consequence of poor measurement in construction as stated in the segment?
    14·1 answer
  • Question 2: (a) In your own words, clearly distinguish and differentiate between Ethics in Engineering and Ethics in Computing (
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!