Min Max Numbers

Description:

Write a program that reads from user a sequence of N integers and return min and max values. Input : 3 1 2 3 Output : min :1 max :3 Input : 4 0 2 9 -1 Output : min :-1 max :9 Test Case 1 Input (stdin) 3 1 2 3 Expected Output Min=1 Max=3 Test Case 2 Input (stdin) 5 12 33 44 -99 123 Expected Output Min=-99 Max=123

Program :

#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 << "Min=" <<min<<"\n";

    cout << "Max=" <<max;

    return 0;

}