Answer to Question #212276 in C++ for fazily

Question #212276

C++ PROGRAMMING

The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5 

Table 1- Machine "A" Production

1 2 3 4

Array index 0 1 2 3

Production 15.5 25.5 27.5 60.5

Table 2- Machine "B" Production

1 2 3 4

Array index 0 1 2 3

Production 50 45.5 25.5 18

Table 3- Machine "C" Production

1 2 3 4

Array index 1 2 3

Production 35.5 65 71 74.5

(a) Write a function using C++ statements called InputProduction() which takes a float array and an integer (as the size of the array) as parameters. The method should ask the user to insert production of each machine and fill the array. The values are entered through the keyboard and range between 15.5 and 75.5.


1
Expert's answer
2021-06-30T13:44:55-0400
#include<iostream>
using namespace std;
float * InputProduction(float arr[] , int N){
	
	for(int i=0;i<N; i++){
		cout<<"Enter element: \t"<<(i+1);
		cout<<"\t"<<endl;
		cin>>arr[i];
	}
	
	return arr;
}
int main(){
	float *ptr;
	cout<<"Enter the size of the array:"<<endl;
	int N;
	cin>>N;
	float arr[N];
	cout<<"Enter the values to fill the arrays:"<<endl;
	ptr = InputProduction(arr, N);
    	cout<<"The values entered are: "<<endl;
	for(int i=0; i<N; i++){
		cout<<ptr[i]<<endl;
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS