Answer:
#include <stdio.h>
int main()
{
int callsReceived, operatorsOnCall;
scanf("%d", &callsReceived);
scanf("%d", &operatorsOnCall);
if(callsReceived>=0 && operatorsOnCall>0)
{
printf("%d",callsReceived/operatorsOnCall);
}
else
{
printf("INVALID") ;
} }
Explanation:
The programming language to use here is C.
There is an int type variable named callsReceived
Another int type variable is operatorsOnCall
scanf is used to read values into callsReceived and operatorsOnCall
printf is used to print the number of calls received per operator which is found by dividing the calls received with the operators on call i.e. callsReceived / operatorsOnCall
Here the callsReceived is the numerator and should be greater than or equal 0 and operatorsOnCall is the denominator and should be less than 0. So an IF condition is used to check if the value stored in operatorsOnCall is greater than 0 and if the value stored in callsReceived is greater than or equal to 0 in order to precede with the division. AND (&&) logical operator is used to confirm that both these conditions should hold for the IF statement to evaluate to TRUE.
In case the input is not valid, the else part is displayed which means that the message INVALID will be displayed.
In C++ cin is used to read from callsReceived and operatorsOnCall and cout is used to display the results of division or the INVALID message in case the IF condition is false. Rest of the code is the same.
cin >> callsReceived;
cin >> operationsOnCall;
if(callsReceived>=0 && operatorsOnCall>0)
cout << (callsReceived/operationsOnCall);
else
cout << "INVALID";