I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
#include <stdio.h>
#define MAX_SIZE 100 // Maximum array size
int main()
{
int arr[MAX_SIZE];
int num, i;
int * ptr = arr; // Pointer to arr[0]
printf("Enter size of array: ");
//Inputting size of the array from user
scanf("%d", &num);
printf("Enter elements in array:\n");
for (i = 0; i < num; i++)
{
scanf("%d", ptr);
// Moving pointer to next array element
ptr++;
}
ptr = arr;
printf("Entered array elements are: ");
for (i = 0; i < num; i++)
{
// Print value pointed by the pointer
printf("%d ", *ptr);
// Move pointer to next array element
ptr++;
}
return 0;
}
I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
Result:
Enter size of array: 5
Enter elements in array:
1
2
3
4
5
Entered array elements are: 1 2 3 4 5
need an explanation for this answer? contact us directly to get an explanation for this answer