Program in C to Accept Numbers from User and Print Number Using "malloc" function
#include<stdio.h>#include<conio.h>
void main()
{
int le,i,*pa;
clrscr();
printf("Enter Total Numbers\n");
scanf("%d",&le);
pa=(int*)malloc(le*sizeof(int));
printf("\nEnter %d numbers\n",le);
for(i=0;i<=le-1;i++)
{
scanf("%d",(pa+i)); //Accepting Numbers
}
printf("\nPrinting Numbers\n");
for(i=0;i<=le-1;i++)
{printf("%d\n",*(pa+i)); //Printing Numbers
}
getch();
}
No comments:
Post a Comment