Perform a task with malloc statement | C-Program

malloc() statement:

Code:

#include<stdio.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));

}

Output:

Comment for your feedback!

Comments

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :