Question: Write a program using both: functions and arrays with the following example: #include using namespace std; int main() { const int N = 4; double
Write a program using both: functions and arrays with the following example:
#include
using namespace std;
int main() { const int N = 4; double num[N]; double max; int p; for (int i = 0; i < N; i++) { cout << "value " << i + 1 << ": "; cin >> num[i]; } max = num[0]; p = 0;
for (int i = 1; i < N; i++) { if (num[i] > max) { max = num[i]; p = i; } } cout << "max value = " << max << endl; cout << "position in the array = " << p << endl;
system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
