write a program in C++ to find the largest value in an array
Answers
Answered by
0
you can refer google for this
Answered by
0
#include<iostream>
using namespace std;
int main ()
{
int arr[10], n, i, max, min;
cout << "Enter the size of the array : ";
cin >> n;
cout << "Enter the elements of the array : ";
for (i = 0; i < n; i++)
cin >> arr[i];
max = arr[0];
for (i = 0; i < n; i++)
{
if (max < arr[i])
max = arr[i];
}
min = arr[0];
for (i = 0; i < n; i++)
{
if (min > arr[i])
min = arr[i];
}
cout << "Largest element : " << max;
cout << "Smallest element : " << min;
return 0;
}
Similar questions
English,
6 months ago
Science,
6 months ago
English,
6 months ago
Math,
1 year ago
Environmental Sciences,
1 year ago
Political Science,
1 year ago