You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
void printArraySized(int arr[3], int n)
{
cout << "Array as Sized Array Argument: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
// passing array as an unsized array argument.
void printArrayUnsized(int arr[], int n)
{
cout << "Array as Unsized Array Argument: ";
for (int i = 0; i < n; i++) {
cout << *(arr + i) << " ";
}
cout << endl;
}
// Passing array as a pointer argument.
void printArrayPointer(int* ptr, int n)
{
// Print array elements using pointer pointer.
// that store the address of array passed.
cout << "Array as Pointer Argument: ";
for (int i = 0; i < n; i++) {
cout << ptr[i] << " ";
}
}
int main()
{
int arr[] = { 10, 20, 30 };
// Call function print Array and pass array and its size to it.
printArraySized(arr, 3);
printArrayUnsized(arr, 3);
printArrayPointer(arr, 3);
return 0;
}
Output ☞
Array as Sized Array Argument :10 20 30
Array as Unsized Array Argument: 10 20 30
Array as Pointer Argument: 10 20 30
The text was updated successfully, but these errors were encountered:
#include < iostream >
using namespace std;
// passing array as a sized array argument.
void printArraySized(int arr[3], int n)
{
cout << "Array as Sized Array Argument: ";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
// passing array as an unsized array argument.
void printArrayUnsized(int arr[], int n)
{
cout << "Array as Unsized Array Argument: ";
for (int i = 0; i < n; i++) {
cout << *(arr + i) << " ";
}
cout << endl;
}
// Passing array as a pointer argument.
void printArrayPointer(int* ptr, int n)
{
// Print array elements using pointer pointer.
// that store the address of array passed.
}
int main()
{
}
Output ☞
Array as Sized Array Argument :10 20 30
Array as Unsized Array Argument: 10 20 30
Array as Pointer Argument: 10 20 30
The text was updated successfully, but these errors were encountered: