Input a list of positive numbers (terminated by 0) into an array, find the largest number in the array, and output the result. Use a subprogram to input the numbers, a function to find the largest number, and a subprogram to output the result.
1
Expert's answer
2012-04-19T07:33:27-0400
On c++: include <iostream>
using namespace std;
int max_func(int a[n]) {
int max = -9999;
for(int i = 0; i<n; i++){
if(a[i]>max){
max = a[i];
}
}
return max;
};
int main() {
int n, arr[];
cout<<"Please, input array size: ";
cin>>n;
for(int i = 0; i<n; i++){
arr[i]=i;
}
cout<<"Max value of this array is: "<<max_func(arr[n]);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment