Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. // Integer Array
  2. int billy[] = {16, 2, 77, 40, 12071};
  3.  
  4. // Calculates number of integers in the array
  5. int sizeofarray = sizeof (billy) / sizeof (billy[0]);
  6.  
  7. void ArrayTotal (int a[])
  8. {
  9.     cout << "The contents of the array are, ";
  10.     int result = 0;
  11.     for (int n = 0; n < sizeofarray; n++) {
  12.         cout << a[n] << ", ";
  13.         result += a[n];
  14.     }
  15.     cout << newline;
  16.     cout << "The total of the array is " << result;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement