home
Learn
screen_rotation
#include <stdio.h> #include <stdlib.h> #include <conio.h> void main(){ int n,i,*ptr,sum=0; clrscr(); printf("\nEnter number of elements: "); scanf("%d",&n); ptr=(int*)calloc(n, sizeof(int)); if(ptr==NULL) { printf("\nSorry! Number of element has not given by you."); exit(0); } for(i=0;i< n;i++) { printf("\nEnter elements of array: "); scanf("%d",ptr+i); } for(i=0;i< n;i++) { printf("\n given element: %d",*(ptr+i)); sum = sum + *(ptr+i); } printf("\n Sum=%d",sum); free(ptr); getch(); }
Program Output
Enter number of elements: 6 Enter elements of array: 5 Enter elements of array: 10 Enter elements of array: 15 Enter elements of array: 20 Enter elements of array: 25 Enter elements of array: 30 given element: 5 given element: 10 given element: 15 given element: 20 given element: 25 given element: 30 Sum=105