repl.it
@dviejo/

QuizzicalDaringNaga

C

No description

fork
loading
Files
  • main.c
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "stdio.h"
#define ROWS 5

int* fn_input(){
	static int   intArr[ROWS];
	int i;

	// Requests users to enter the value for elements 
	for (i = 0; i< ROWS; i++) {
		printf("Enter the value for array intArr[%d]:", i);
		scanf("%d", &intArr[i]);
	}
	return intArr; // return array pointer
}

int main()
{
	int *intPtr;
	int i;

	intPtr = fn_input(); // accepts the pointer to an array

	printf("\nArray Elements are:\n");
	for (i = 0; i< ROWS; i++)
		printf("%d\t", *(intPtr + i)); // displays the values as if it is accessing the array itself

	return 0;
}