#include<stdio.h>
#include<stdlib.h>
int main(){
int *arr;
int i,n;
printf("Enter no of elements:");
scanf("%d",&n);
printf("Entered no is:%d",n);
arr = (int*)calloc(n , sizeof(int));
if(arr == NULL){
printf("\nMemory not allocated");
exit(0);
}
else{
printf("\nMemory successfully allocated using calloc");
for(i=0;i<n;++i){
arr[i] = i + 1;
}
printf("\nElement of array are: ");
for(i=0;i<n;++i){
printf("%d,",arr[i]);
}
printf("\nAddress of array are: ");
for(i=0;i<n;++i){
printf("%d,",&arr[i]);
}
}
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter