Advertisement
Spocoman

05. Average Number

Sep 11th, 2023
887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7.     int num, number;
  8.     cin >> num;
  9.  
  10.     int sum = 0;
  11.  
  12.     for (int i = 0; i < num; i++) {
  13.         cin >> number;
  14.         sum += number;
  15.     }
  16.  
  17.     double average = 1.0 * sum / num;
  18.     printf("%.2f\n", average);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement