+ 2
what should be typed in blanks to get largest element of the array of 10 elements?
2 ответов
+ 4
"x" and "max" are the answers. That "if" statement works as follows. If a number is greater than the current maximum, make it maximum.
+ 2
#include <iostream>
using namespace std;
int main() {
int arr [10];
for(int x=0;x<10;x++)
{
cin>>arr [x];
}
int max = arr[0];
for(int x=0;x<10;x++)
{
if (arr[x]>max)
max=arr[x];
}
cout << max;
}