1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Allisa [31]
3 years ago
10

NOTE: in mathematics, division by zero is undefined. So, in C , division by zero is always an error. Given a int variable named

callsReceived and another int variable named operatorsOnCall, write the necessary code to read values into callsReceived and operatorsOnCall and print out the number of calls received per operator (integer division with truncation will do). HOWEVER: if any value read in is not valid input, just print the message "INVALID". Valid input for operatorsOnCall is any value greater than 0. Valid input for callsReceived is any value greater than or equal to 0.
Computers and Technology
1 answer:
Sergio [31]3 years ago
8 0

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";

You might be interested in
Choose the best technology device for the
Oxana [17]

Answer:

Desktop computer with 2 screens

Explanation:

All graphices designers need the most screen space possible

8 0
2 years ago
The function below takes one parameter: a string (date_string) containing a date in the mm/dd/year format. Complete the function
Natalija [7]

Answer:

The solution code is written in Python 3.

  1. def convertDate(date_string):
  2.    date_list = date_string.split("/")
  3.    for i in range(0, len(date_list)):
  4.        date_list[i] = int(date_list[i])
  5.    return date_list  
  6. print(convertDate('06/11/1930'))

Explanation:

Firstly, create a function convertDate() with one parameter, <em>date_string</em>. (Line 1).

Next, use the Python string <em>split()</em> method to split the date string into a list of date components (month, day & year) and assign it to variable <em>date_list</em>. (Line 3) In this case, we use "/" as the separator.

However, all the separated date components in the <em>date_list</em> are still a string. We can use for-loop to traverse through each of the element within the list and convert each of them to integer using Python<em> int() </em>function. (Line 5 - 6)

At last return the final date_list as the output (Line 8)

We can test our function as in Line 11. We shall see the output is as follow:

[6, 11, 1930]

8 0
2 years ago
What is an example of constructive criticism for an employee who frequently arrives late?
aleksley [76]
I believe the correct answer is A
5 0
3 years ago
Read 2 more answers
Which of the following statements is true of infrastructure?
bazaltina [42]

Answer:

Examples of infrastructure include transportation systems, communication networks, sewage, water, and electric systems. Projects related to infrastructure improvements may be funded publicly, privately, or through public-private partnerships.

3 0
1 year ago
A compression scheme for long strings of bits called run-length encoding is described as follows: Rather than record each 0 and
Musya8 [376]

Answer: (B) Lossless compression

Explanation:

 According to the question, the given technique is the example of the lossless compression. The lossless compression is one of the technique that decompress the data into the original data form without any type of losses.

The lossless compression is the technique that usually compress the data, text and the databases. This technique also improve the compression rate helps in reconstruct the original data. It is used in various types of encoding methods, GNU tool and zip file.

3 0
3 years ago
Other questions:
  • When an architect designs a building, what visual design elements could be used to help capture a viewer’s attention? A) The use
    5·2 answers
  • To begin importing data from an excel spreadsheet, click on the ____ tab on the ribbon.
    11·1 answer
  • To save and store data separate from a computer, it helps to have an
    15·2 answers
  • An administrator is helping a user connect a smartphone to a tablet via Bluetooth. What should the administrator do first?
    6·1 answer
  • There are....... section in<br>cpu<br>​
    15·1 answer
  • Sally types documents that have a few numbers but mostly letters. To enter these numbers, she should use the
    12·1 answer
  • Jill is configuring the AutoArchive feature in Outlook 2016. What is the default setting in relation to when AutoArchive
    8·1 answer
  • Which protocol is well known for its use in the the home security and home automation industry, uses a mesh topology, makes devi
    7·1 answer
  • Select the correct answer..
    6·1 answer
  • Bluetooth is the popular name for the 802. 15 wireless networking standard, which is useful for creating small __________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!