ans 2
unknown
c_cpp
4 years ago
557 B
12
Indexable
#include<stdio.h>
#include<stdlib.h>
int main(int argc,char** argv)
{
int* arr;
int n=5;
// Dynamically allocate memory using calloc()
arr = (int*)calloc(n, sizeof(int));
// Memory has been successfully allocated
printf("Memory successfully allocated using calloc.\n");
for (int i = 0; i < n; ++i) {
arr[i] = i + 1;
}
printf("The elements of the array are: ");
for (i = 0; i < n; ++i) {
printf("%d, ", arr[i]);
}
}
return 0;
}
Editor is loading...