Rize S. answered 03/23/23
Senior IT Certified Trainer, IT Developer & DBA Administrator
Here's an example code snippet in C++ that reads values into callsReceived and operatorsOnCall, performs the required calculation, and prints the output:
#include <iostream>
using namespace std;
int main() {
int callsReceived, operatorsOnCall;
// Read values into callsReceived and operatorsOnCall
cout << "Enter the number of calls received: ";
if (!(cin >> callsReceived)) {
cout << "INVALID" << endl;
return 0;
}
cout << "Enter the number of operators on call: ";
if (!(cin >> operatorsOnCall)) {
cout << "INVALID" << endl;
return 0;
}
// Calculate and print the number of calls received per operator
if (operatorsOnCall != 0) {
int callsPerOperator = callsReceived / operatorsOnCall;
cout << "Number of calls received per operator: " << callsPerOperator << endl;
} else {
cout << "INVALID" << endl;
}
return 0;
}
This code first reads in the values for callsReceived and operatorsOnCall from the user. It checks if the input is valid and prints "INVALID" if it is not. If the input is valid, it performs the integer division callsReceived / operatorsOnCall to calculate the number of calls received per operator, and prints the result. If the number of operators on call is zero, it prints "INVALID" instead of performing the calculation to avoid a divide-by-zero error.