-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram126.c
More file actions
44 lines (35 loc) · 787 Bytes
/
Copy pathprogram126.c
File metadata and controls
44 lines (35 loc) · 787 Bytes
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
#include<stdio.h>
#include<stdlib.h>
void Display(int Arr[],int iSize)
{
int iCnt = 0;
printf("Entered element");
for(iCnt = 0 ; iCnt < iSize; iCnt++)
{
printf("%d",Arr[iCnt]);
}
}
int main()
{
int iLength = 0,iCnt =0;;
int *ptr = NULL;
printf("Enter the NUmber of the Element :\n");
scanf("%d",&iLength);
// Step 1: Allocate the memory
ptr = (int *)malloc(iLength * sizeof(int));
if(ptr == NULL)
{
printf("Unable to allocate memory");
return -1;
}
printf("Enter the element:\n");
for(iCnt = 0; iCnt < iLength; iCnt++)
{
scanf("%d",&ptr[iCnt]);
}
// Step 2: Use the memory
Display(ptr,iLength);
// Step 3: Free the memory
free(ptr);
return 0;
}