Wednesday, January 13, 2021

Allocate memory to array and find out maximum value from array

 


#include <iostream>
using namespace std;
int main()
{
    int n[2000], *psmax = 0;
    // allowcate memory to array
    p = new int[2000];
    // take size of arry from user
    cout << "Enter the size of array" << endl;
    cin >> s;
    // take input of array from user
    for (int i = 0i < si++)
    {
        cout << "Enter the value of n[" << i << "] " << endl;
        cin >> *(p + i);
        // find out maximum value from array
        if (*(p + i) > max)
        {
            max = *(p + i);
        }
    }
    // show maximum value of array
    cout << "Largest value of array is :" << max << endl;

    return 0;
}

No comments:

Post a Comment