The problem is to create a function that prints out n numbers of the array and their addresses. Function should be called 3 times in the main. The function can only have two parameters. 1. it will print all members of the array 2. it will print elements from 0-4 3. it will print elements 3-9
I have made a body of the function but I am struggling with following the condition of having only two parameters. One of them is already used to pass the array to the function so there is only one left.
#include <stdio.h>
#define size 10
void Input (int arr[]);
void AdressOutput (int arr[]);
int main(void)
{
int arr[size];
Input(arr);
AdressOutput(arr);
return 0;
}
void Input (int arr[])
{
int i;
int *p=arr;
for (i=0;i<size;i++)
{
printf ("Please enter a value %d - ",i);
scanf ("%d",(p+i));
}
printf ("\n");
}
void AdressOutput (int arr[])
{
int i=0;
int *p=arr;
for (i=0;i<size;i++)
{
printf ("%p,%d\n",(p+i),*(p+i));
}
}
The only thing I was able to come up with is to create two more parameters (plus array) starting and ending variables which can be different every time I call the function, but somehow I only need to keep it only with two parameters.