C Program For malloc() and calloc() Function
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
//Diffrence between malloc and calloc function for Dynamic memory
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
int *ar,n,i;
printf("%d",sizeof(int));
printf("Enter the limit");
scanf("%d",&n);
ar= (int*)calloc(sizeof(int),n); // n block of 4 size
printf("Enter elements in array");
for(i=0;i<n;i++)
scanf("%d",&ar[i]);
for(i=0;i<n;i++)
printf("%d",&ar[i]);
free(ar);
}
If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

