-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPointers and Arrays
50 lines (37 loc) · 963 Bytes
/
Pointers and Arrays
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Humza KHawar BSCS-10-C (343114)
Lab Task
Inputting and Outputting Arrays using Pointors
*/
#include<stdio.h>
void Input_Function(int*, int); //Function to take input using pointors
void Output_Function(int*, int); //Function to print output using pointors
void main()
{
//initiallization
int arr[100] = { 0 }, numbers;
//taking the number of elements from user
printf("\nEnter Number of elements : ");
scanf("%d", &numbers);
//passing adress of array to input function
Input_Function(arr, numbers);
//passing adress of array to output function
Output_Function(arr, numbers);
}
void Input_Function(int* arr,int n) {
//loop to take input
for (int i = 0; i < n; i++)
{
printf("\n Enter Number %d : ", i + 1);
scanf("%d", arr + i);
}
}
void Output_Function(int* arr, int n) {
//loop to print output input
printf("\n Your Array is : ");
for (int i = 0; i < n; i++)
{
printf(" %d ", *(arr + i));
}
printf("\n\n");
}