My Profile

I, Das ShrikKrishna J. MCA III IMSCD&R, Ahmednagar.

Monday, 15 August 2011

Number Using "malloc" function

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

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls