MEMORY ALLOCATION - calloc()

Опубликовано: 11 Сентябрь 2026
на канале: Solution Manual
9
0

int main()
{
int i,n,*p;

printf("\n Enter the Number of Elements : \n");
scanf("%d",&n);

// MEMORY ALLOCATION USING CALLOC() FUNCTION

p=(int*)calloc(n,sizeof(int));

// TO PRINT THE ADDRESS OF MEMORY LOCATION
for(i=0;i lt n;i++)
{
printf("\nAddress of Location %d is :::::: \t %d\n",i,&p[i]);
}

// TO GET ELEMENTS FROM USER
for(i=0;i lt n;i++)
{
printf("\nEnter the Element \n");
scanf("%d",&*(p+i));
}

//PRINT THE ELEMENTS
printf("\n::::The Elements in Memory Location ::::");
for(i=0;i lt n;i++)
{
printf("\n%d\n",*(p+i));
}
return 0;
}