Created
January 2, 2018 15:36
-
-
Save Dviejopomata/25ce26172876e363b74185bfc958e94c to your computer and use it in GitHub Desktop.
QuizzicalDaringNaga created by dviejo - https://repl.it/@dviejo/QuizzicalDaringNaga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment