Week 10 In-Class Examples

Arrays:

#include <iostream>
#include <cmath>
#include <iomanip> using namespace std; int main(void) { const int num_elements = 10; int i; int summ = 0; int my_array[num_elements]; for (i = 0; i < num_elements; i++) { cout << "Enter value for location " << i << ": "; cin >> my_array[i]; } for (i = 0; i < num_elements; i++) { summ = summ + my_array[i]; } cout << "The total of all elements is " << summ << endl; return 0; }