xxxxxxxxxx
#include <iostream>
using namespace std;
struct Array
{
int A[20];
int size;
int length;
};
void Display(struct Array arr)
{
cout<<"Elements of the array are ";
for(int i=0;i<arr.length;i++)
{
cout<<arr.A[i]<<" ";
}
}
void Append(struct Array *arr, int x)
{
if(arr->size>arr->length) //comparing size and length
{
arr->A[arr->length++] = x;
}
}
int main()
{
struct Array arr = {{10,20,30,50,60},10,5}; //array Elements, size, length
Append(&arr,70); // array element, appending element
Display(arr);
}Copy