daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void printArray(double arr[], int arrSz, char splitter = ' ') {
  6.     for (int i = 0; i < arrSz; i++) {
  7.         cout << arr[i] << splitter;
  8.     }
  9.     cout << endl;
  10. }
  11.  
  12. double getAverageNumber(double arr[], int arrSz) {
  13.     double averageNumber = 0;
  14.     for (int i = 0; i < arrSz; i++) {
  15.         averageNumber += arr[i];
  16.     }
  17.     return averageNumber / arrSz;
  18. }
  19.  
  20. int main() {
  21.     const int CSize = 7;
  22.     double C[CSize];
  23.  
  24.     cout << "Enter numbers for next elements from C array:" << endl;
  25.     for (int i = 0; i < CSize; i++) {
  26.         cout << "C[" << i << "]: ";
  27.         cin >> C[i];
  28.     }
  29.     cout << endl;
  30.  
  31.     cout << "Element values of C array: ";
  32.     printArray(C, CSize);
  33.  
  34.     cout << "Average value of C array: " << getAverageNumber(C, CSize) << endl;
  35.  
  36.     system("pause");
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top