Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- int *p, i, n, a;
- printf("Enter the size of the array: \n\n");
- scanf("%d", &a);
- p = (int*)calloc(a, sizeof(int));
- if(p==NULL)
- {
- printf("Memory allocation failed");
- exit(1);
- }
- for(i = 0; i < a; i++)
- {
- printf("Enter element at index %d: ", i);
- scanf("%d", p+i);
- }
- int j;
- printf("IncreasinG the size of the array by elements ...\n " );
- scanf("%d", &j);
- p = (int*)realloc(p, j * sizeof(int));
- if(p==NULL)
- {
- printf("Memory allocation failed");
- exit(1);
- }
- printf("\nEnter %d more integers\n\n",j);
- for(i = a; i < (j+a); i++)
- {
- printf("Enter element at index %d: ", i);
- scanf("%d", p+i);
- }
- printf("\nFinal array: \n\n");
- for(i = 0; i < (j+a); i++)
- {
- printf("%d ", *(p+i) );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement