write a programme to dynamically create an arry to capable of storing integers in c

 #include<stdio.h>

#include<stdlib.h>


int main()

{

  int *ptr;

  int n;

  ptr = (int *)malloc(n*sizeof(int));

  

  printf("Enter the value of n\n");

  scanf("%d",&n);

  

  for(int i=0; i<n ; i++){

  printf("Enetr the value of %d element:\n",i+1);

  scanf("%d",&ptr[i]);

  }

  

  for(int i=0; i<n ; i++){

  printf("\nThe elements of %d is: %d\n",i+1,ptr[i]);

  }

  

  free(ptr);

  

  return 0;

}

Comments

Popular posts from this blog

create a num table in a new file in c

write a programme to compare time stamp in c

write a struct programme to keep bank details in c