#include <stdio.h>\n#include <stdlib.h>\n\nint main()\n{\n int *ptr;\n int n;\n\n printf("Enter the no of elements you want in an array1:");\n scanf("%d",&n);\n printf("The no of elements in array 1 would be %d",n);\n\n ptr=(int*)malloc(n*sizeof(int));\n if(ptr==NULL){\n printf("Memory not alloted ");\n }\n else{\n printf("Memory successfully alloted using malloc");\n }\n\n printf("The elements of array 1 are:");\n for(int i=0;i<n;i++){\n ptr[i]=2*i;\n printf("%d",ptr[i]);\n }\n free(ptr);\n printf("Memory has been successfully freed\\n");\n\n int *ptr1,n1;\n printf("Enter the no of elements you want in an array2:\\n");\n scanf("%d",&n1);\n printf("The no of elements in array 2 …
Run Code Online (Sandbox Code Playgroud)