We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
because you have allocated memory to pointer ar using malloc function before taking the value of n from user. you should first take input n from user and then allocate memory to the pointer, i.e.
first use scanf("%d",&n);
then write int ar=(int)malloc(sizeof(int)*n);
hope, you understand.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
because you have allocated memory to pointer ar using malloc function before taking the value of n from user. you should first take input n from user and then allocate memory to the pointer, i.e. first use scanf("%d",&n); then write int ar=(int)malloc(sizeof(int)*n);
hope, you understand.