/******************************************************************************************** ex1.cpp Jim Millard for CO311 Basic array processing ********************************************************************************************/ #include <iostream> #include <string> using namespace std; void ParseAndPrint(char [], int); void ParseAndPrint(int [], int); void main() { int Frequency[5] = {100, 99, 98, 97, 96}; int Total[5] = {0}; int Sum[5]({-2, -1, 0, 1, 2}); int Count[5]({37}); int Result[5]; int Digits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int Zero[] = {0}; char Alphabet[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; char HB[] = "Happy Birthday!"; cout << "Frequency: "; ParseAndPrint(Frequency, 5); cout << "Total: "; ParseAndPrint(Total, 5); cout << "Sum: "; ParseAndPrint(Sum, 5); cout << "Count: "; ParseAndPrint(Count, 5); cout << "Result: "; ParseAndPrint(Result, 5); cout << "Digits: "; ParseAndPrint(Digits, 10); cout << "Zero: "; ParseAndPrint(Zero, 1); cout << "Alphabet: "; ParseAndPrint(Alphabet, 26); cout << "HB: "; ParseAndPrint(HB, 15); // cout << endl << "Object Size Info" << endl; // cout << "sizeof(Digits): " << sizeof(Digits) << " bytes" << endl; // cout << "sizeof(int): " << sizeof(int) << " bytes" << endl; // cout << "sizeof(Digits)/sizeof(int): " << sizeof(Digits)/sizeof(int) << " elements\n"; // cout << "sizeof(Alphabet): " << sizeof(Alphabet) << " bytes" << endl; // cout << "sizeof(char): " << sizeof(char) << " byte" << endl; // cout << "sizeof(Alphabet)/sizeof(char): " << sizeof(Alphabet)/sizeof(char) << " elements\n"; // cout << "sizeof(HB): " << sizeof(HB) << " bytes" << endl; // cout << endl << "Other size information" << endl; // cout << "Floating-point: " << sizeof(float) << " bytes" << endl; // cout << "double precision: " << sizeof(double) << " bytes" << endl; // cout << "long double: " << sizeof(long double) << " bytes" << endl; // cout << "long integer: " << sizeof(long int) << " bytes" << endl; } void ParseAndPrint(char array[], int size) { for (int i = 0; i < size; i++) cout << array[i]; cout << endl; } void ParseAndPrint(int array[], int size) { for (int i = 0; i < size; i++) cout << array[i] << ' '; cout << endl; }