answersLogoWhite

0


Best Answer

#include <stdio.h> #include <stdlib.h> int main(){ int n,i,*ptr,sum=0; printf("Enter number of elements: "); scanf("%d",&n); ptr=(int*)malloc(n*sizeof(int)); //memory allocated using malloc if(ptr==NULL) { printf("Error! memory not allocated."); exit(0); } printf("Enter elements of array: "); for(i=0;i<n;++i) { scanf("%d",ptr+i); sum+=*(ptr+i); } printf("Sum=%d",sum); free(ptr); return 0; }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Unix cprogram based on dynamic memory allocation to find the minimum and maximum set of numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp