Advertisement
Dido09

C - Array Average

May 29th, 2022
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.  
  4.  int values[10], i, n, sum = 0, average;
  5.  
  6.  printf("Enter the number of elements you wish to add to the array: ");
  7.  scanf("%d", &n);
  8.  
  9.  for(i = 0; i < n; i++){
  10.     printf("Enter number: ", i);
  11.     scanf("%d", &values[i]);
  12.  
  13.     sum = sum + values[i];
  14.  }
  15.  
  16.  average = sum / n;
  17.  printf("%d", average);
  18.  
  19.   return 0;
  20. }
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement