#include<iostream>
using namespace std;
void f1(int a[], int size) //A user-defined function which takes an 'int array' as arguments
{
for(int i=0;i<size;i++)
{
cout<<a[i]<<endl;
}
}
int main()
{
int ar[]={1,2,3,4,5,6,7,8,9,10,11};
f1(ar,7); //passing array name and no. of elements(less than actual) to be displayed as args
f1(ar,11); //passing array name and no. of elements(equal to actual) to be displayed as args
f1(ar,15); //passing array name and no. of elements(more than actual) to be displayed as args
return 0;
}
using namespace std;
void f1(int a[], int size) //A user-defined function which takes an 'int array' as arguments
{
for(int i=0;i<size;i++)
{
cout<<a[i]<<endl;
}
}
int main()
{
int ar[]={1,2,3,4,5,6,7,8,9,10,11};
f1(ar,7); //passing array name and no. of elements(less than actual) to be displayed as args
f1(ar,11); //passing array name and no. of elements(equal to actual) to be displayed as args
f1(ar,15); //passing array name and no. of elements(more than actual) to be displayed as args
return 0;
}
No comments:
Post a Comment