include iostream include conio using namespace std int main const int

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
const int n = 8;
int arr[n];
cout << "Enter arr: ";
for(int i = 0; i < n; i++)
{
cout << "\n[" << i << "]: ";
cin >> arr[i];
}
int max = arr[0];
for(int i = 0; i < n; i++)
if(arr[i] > max)
max = arr[i];
cout << "\nMax element is " << max;
int sum = 0;
for(int i = 0; i < n; i++)
{
if(arr[i] < 0)
break;
sum += arr[i];
}
cout << "\nSum is " << sum;
getch();
}