Advertisement
Waliul

2. Calculate an average of 20 numbers using array

Sep 9th, 2021
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, i, j, k, temp, sum;
  6.     n = 10;
  7.     sum = 0;
  8.     int arr[n];
  9.     printf("Enter the %d numbers : ", n);
  10.     for(i = 0; i < n; i++)
  11.         scanf("%d", &arr[i]);
  12.  
  13.     for(i = 0; i < n; i++)
  14.         sum += arr[i];
  15.  
  16.     printf("\nThe average of those numbers : %f\n", (float)sum/n);
  17.     return 0;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement