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
Describe the "Bauschinger Effect" on the stress strain behaviour of steel
Rom4ik [11]

Answer:

The Bauschinger effect is the directionally determined change in the elasticity limit of a metal or alloy after primary plastic deformation. If you first deform a metal in one direction so that it is plastically deformed and then deform it in the opposite direction, the elastic limit in the opposite direction is lower.

From the point of view of the dislocation mechanism of plastic deformation, the Bauschinger effect indicates that during repeated deformation, it is easier for dislocations blocked in front of obstacles to move in the direction opposite to their movement during preliminary plastic deformation.

7 0
4 years ago
Which two statements about professional technical jobs in the energy industry are correct?
Tanya [424]
The answer is both B and D
4 0
3 years ago
Read 2 more answers
Which of the following is true about silicosis?
user100 [1]

Answer:

D. The damage it causes is irreversible

Explanation:

Silicosis is a long term lung disease caused by crystalline silica dust inhalation. There is no cure, and once the damage is done it cannot be reversed.

------------------

Like stated above, the damage is irreversible. Option A is incorrect.

Construction workers are constantly moving to build whatever they're working on. The disease will make it hard to breathe and will have a heavy effect on their lungs, preventing them from properly doing their jobs. Additionally, it's possible to get the disease from this job since you're constantly inhaling dust particles.

Silicosis does major damage to the lungs. The dust particles are attacked by the immune system which causes inflammation and eventually leads to areas of hardened and scarred lung tissue.

Thus, the best option is D.

hope this helps :)

5 0
2 years ago
While discussing run-flat tires: Technician A says that some are self-sealing tires and are designed to quickly and permanently
musickatia [10]

Answer:

The correct option is d ( Neither A nor B)

Explanation:

Technician A made 2 mistakes in his statement.Firstly the tire is self supporting not self sealing.

Secondly, this tire does not provide permanent sealing of punctured area option a is incorrect.

This self-supporting tire after being affected with complete air leakage can temporarily bear the load of the car and avoid rolling over a distance of 80 km at a maximum speed of 55 mph. Here is what technician B suggested incorrectly as the tire after being.Here the technician B suggested incorrectly as the tire after being affected with puncture can not travel at any speed so option B is wrong

Since option a and b are incorrect and c is invalid.

4 0
3 years ago
Why a brass lid ring on a glass canning jar will loosen when heated.
Zolol [24]

hi here is your answer hope it helps or then sry

Explanation:

A brass lid on a glass canning jar will loosen when heated because brasshas the greater coefficient of thermal expansion 

4 0
3 years ago
Other questions:
  • Problem 1: Experts on hypothermia tell us that heat loss from the body is much greater in 10°C water than in air at the same tem
    9·1 answer
  • A vegetable freezing plant requires 35 tons of refrigeration. The freezing temperature is – 38°C while the ambient temperature i
    14·1 answer
  • A source which can be represented by a 12 V rms voltage source in series with a resistance of 1.5 k is connected to a 75- load r
    13·1 answer
  • The fluid-conditioning components of hydraulic-powered equipment provide fluid that is clean and maintained at an acceptable ope
    6·1 answer
  • 7. The "3 second rule" is the time you should pause at an intersection marked with a stop sign.
    6·1 answer
  • What sub-discipline of Mechanical Engineering focuses
    10·1 answer
  • A mixing chamber receives a steady flow of water from different parts of a processing plant. It has two inlets and one outlet. T
    5·1 answer
  • According to the rules of dimensioning, how should the written notes appear?
    8·1 answer
  • a wire is not strong enough to pick up a washer or much of anything. what is a way to strengthen the magnetic field?
    15·1 answer
  • What are these tools called need help with it?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!