#include <stdio.h>
#include <stdlib.h>
int main()
{
int *P_Pointer,*P_Table;
int V_Size;
printf("What must be the size of table? ");
scanf("%d",&V_Size);
/*--Memory Allocation--*/
if((P_Table=(int*)malloc(V_Size*sizeof(int)))==NULL)
{
printf("There is no space available in the Memory");
exit(1);
}
printf("Address of the first location in the allocated table is %u\n",P_Table);
/*Store some data in the allocated memory*/
printf("Enter the values to be stored");
for(P_Pointer=P_Table;P_Pointer<P_Table+V_Size;P_Pointer++)
{
scanf("%d",P_Pointer);
}
/*Print the stored values in the allocated memory*/
for(P_Pointer=P_Table;P_Pointer<P_Table+V_Size;P_Pointer++)
{
printf("%d is stored at address %u \n",*P_Pointer,P_Pointer);
}
}
#include <stdlib.h>
int main()
{
int *P_Pointer,*P_Table;
int V_Size;
printf("What must be the size of table? ");
scanf("%d",&V_Size);
/*--Memory Allocation--*/
if((P_Table=(int*)malloc(V_Size*sizeof(int)))==NULL)
{
printf("There is no space available in the Memory");
exit(1);
}
printf("Address of the first location in the allocated table is %u\n",P_Table);
/*Store some data in the allocated memory*/
printf("Enter the values to be stored");
for(P_Pointer=P_Table;P_Pointer<P_Table+V_Size;P_Pointer++)
{
scanf("%d",P_Pointer);
}
/*Print the stored values in the allocated memory*/
for(P_Pointer=P_Table;P_Pointer<P_Table+V_Size;P_Pointer++)
{
printf("%d is stored at address %u \n",*P_Pointer,P_Pointer);
}
}
Sample output :
Comments
Post a Comment