Create Dynamic array in C, Store value and print value in created dynamic array.

#include<stdio.h>
#include<conio.h>

void main()
{
  int *a;
  int i,size;
  clrscr();
  printf("Please enter the number of elements you want to insert ");
  scanf("%d",&size);
  a=(int *)calloc(sizeof(int),size);
  for(i=0;i<size;++i)
  {
   printf("Enter the data for element %d :",i+1);
    scanf("%d",i+a);
  }
  printf("\nYour entered numbers are ");
  for(i=0;i<size;++i)
  {
    printf("%d ",*(a+i));
  }
  printf("\nThe address where the value stored are : ");
  for(i=0;i<size;++i)
  {
    printf("\n%d ",&a[i]);
  }

  getch();
}

No comments:

Post a Comment