Friday, 24 November 2017

C++ Program to Implement Variable length array


Code:

#include   iostream
#include   string
using namespace std;

int main()
{
    int *array, size;
    cout<<"Enter size of array: ";
    cin>>size;
    array = new int [size];
    for (int i = 0; i < size; i++)
    {
        cout<<"Enter an integer to be inserted: ";
        cin>>array[i];
    }
    for(int i = 0; i < size; i++)
    {
        cout<
    }
    cout<
    delete []array;
    return 0;
}

Output:

Enter size of array: 5
Enter an integer to be inserted: 3
Enter an integer to be inserted: 4
Enter an integer to be inserted: 2
Enter an integer to be inserted: 5
Enter an integer to be inserted: 1
3  4  2  5  1


------------------
(program exited with code: 1)
Press return to continue


More C++ Programs:















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...