Advertisement
tonygms3

Question 16 Assignment

Dec 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX_SIZE 500
  3. int main()
  4. {
  5.     int arr[MAX_SIZE];
  6.     int i, n, sum=0;
  7.  
  8.     printf("Enter The Size Of The Array: ");
  9.     scanf("%d", &n);
  10.     printf("Enter %d Elements In The Array: \n", n);
  11.  
  12.     for(i=0; i<n; i++)
  13.     {
  14.         scanf("%d", &arr[i]);
  15.     }
  16.  
  17.     for(i=0; i<n; i++)
  18.     {
  19.         sum = sum + arr[i];
  20.     }
  21.     printf("Sum of all elements of array = %d", sum);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement