Perform a task with malloc statement | C-Program
malloc() statement:
Code:
#include<stdio.h>
#include<stdlib.h>
}
#include<stdlib.h>
#include<stdio.h> #include<stdlib.h> void main() { int n,*p,i; printf("Enter the size of elements:\n"); scanf("%d",&n); p=(int*)malloc(n); printf("Enter the elements:\n"); for(i=0;i<n;i++) scanf("%d",p+i); printf("The elements are:\n"); for(i=0;i<n;i++) printf("%d\t",*(p+i));
}
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)