Answer to Question #275186 in C++ for Mod

Question #275186

T is an array of N integers. N is defined as a constant equal to 10.

Write a procedure proc1(int *T) that reads the N elements of the array by checking that the entered values are between 10 and 20. This procedure will display thereafter the N values of the array, the sum value, the maximum value and the minimum value of elements in this array.


1
Expert's answer
2021-12-03T08:21:37-0500
#include<iostream>
#include<conio.h>
using namespace std;


#define N 10
void proc1(int *T){
	for(int i=0;i<N;i++){
		//checking that the entered values are between 10 and 20. 
		int n=0;
		while(n<10 || n>20){
			cout<<"Enter number "<<(i+1)<<": ";
			cin>>n;
		}
		T[i]=n;
	}
	//This procedure will display thereafter the N values of the array, 
	int sum=0;
	int maximum=T[0];
	int minimum=T[0];
	cout<<"\nThe N values of the array: \n";
	for(int i=0;i<N;i++){
		cout<<T[i]<<" ";
		sum+=T[i];
		if(T[i]>maximum){
			maximum=T[i];
		}
		if(T[i]<minimum){
			minimum=T[i];
		}
	}
	//the sum value, the maximum value and the minimum value of elements in this array.
	cout<<"\nThe sum value: "<<sum<<"\n";
	cout<<"The maximum value: "<<maximum<<"\n";
	cout<<"The minimum value: "<<minimum<<"\n";
}


int main()
{




	int *T=new int[N];
	proc1(T);
	
	cin>>T[0];
	return 0;
}

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