Input: The letter A.
Output: The output is the AVERAGE of all the input numbers read so far, calculated as a double number. For example, if there have been four input numbers 2, 2, 6 and 5, then the average is 3.75. If there has not yet been any input numbers, then the program should print the word "ERROR" instead of an average.
int aArray[defaultSize]; //needs to be initialized with a default value
for (int i = 0; i < defaultSize; ++i){
//aArray[i] is set to a default here
}
//assuming you set the array contents starting at position 0
//you only need to check the 0 index
if(aArray[0] == defaultValue){
cout << "ERROR" << endl;
}
else{
//assuming i is the number of integers input
for (int j = 0; j < i; j++)
{
sum = sum + aArray[j];
}
avg = (sum/i); //this calc only needs to be done once and can be put out of loop like this
}
• Input: The letter F.
Output: The output is the most FREQUENT of all the input numbers read so far--in other words, the number that has been read most often (also called the "mode"). If there are several numbers that are equally often, then the smallest number is printed. For example, if there have been four input numbers 2, 2, 6 and 5, then the most frequent is 2. If there has not yet been any input numbers, then the program should print the word "ERROR" instead.
||=== Build: Debug in Assign 7-A (compiler: GNU GCC Compiler) ===|
C:\Users\cbooa1\Desktop\Assign 7-A\main.cpp||In function 'int main()':|
C:\Users\cboo1\Desktop\Assign 7-A\main.cpp|95|error: name lookup of 'j' changed for ISO 'for' scoping [-fpermissive]|
C:\Users\cbaoo1\Desktop\Assign 7-A\main.cpp|95|note: (if you use '-fpermissive' G++ will accept your code)|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|