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
Given parameters b and h which stand for the base and the height of an isosceles triangle (i.e., a triangle that has two equal s
schepotkina [342]

Answer:

The area of the triangle is calculated as thus:

Area = 0.5 * b * h

To calculate the perimeter of the triangle, the measurement of the slant height has to be derived;

Let s represent the slant height;

Dividing the triangle into 2 gives a right angled triangle;

The slant height, s is calculated using Pythagoras theorem as thus

s = \sqrt{b^2 + h^2}

The perimeter of the triangle is then calculated as thus;

Perimeter = s + s + b

Perimeter = \sqrt{b^2 + h^2} + \sqrt{b^2 + h^2} +b

Perimeter = 2\sqrt{b^2 + h^2} + b

For the volume of the cone,

when the triangle is spin, the base of the triangle forms the diameter of the cone;

Volume = \frac{1}{3} \pi * r^2 * h

Where r = \frac{1}{2} * diameter

So, r = \frac{1}{2}b

So, Volume = \frac{1}{3} \pi * (\frac{b}{2})^2 * h

Base on the above illustrations, the program is as follows;

#include<iostream>

#include<cmath>

using namespace std;

void CalcArea(double b, double h)

{

//Calculate Area

double Area = 0.5 * b * h;

//Print Area

cout<<"Area = "<<Area<<endl;

}

void CalcPerimeter(double b, double h)

{

//Calculate Perimeter

double Perimeter = 2 * sqrt(pow(h,2)+pow((0.5 * b),2)) + b;

//Print Perimeter

cout<<"Perimeter = "<<Perimeter<<endl;

}

void CalcVolume(double b, double h)

{

//Calculate Volume

double Volume = (1.0/3.0) * (22.0/7.0) * pow((0.5 * b),2) * h;

//Print Volume

cout<<"Volume = "<<Volume<<endl;

}

int main()

{

double b, h;

//Prompt User for input

cout<<"Base: ";

cin>>b;

cout<<"Height: ";

cin>>h;

//Call CalcVolume function

CalcVolume(b,h);

//Call CalcArea function

CalcArea(b,h);

//Call CalcPerimeter function

CalcPerimeter(b,h);

 

return 0;

}

3 0
2 years ago
Which of the following is a best practice regarding the Administrator account?
lara31 [8.8K]

Answer:

B. The account should be given a nondescript account name that cannot be easily guessed.

3 0
3 years ago
How would a password be a good password, how, and why.
Pachacha [2.7K]

Answer:

Complicated

Explanation:

A good password is something that can't just be guessed like cupcake it has to be like CUp_c3k3_456

4 0
2 years ago
Read 2 more answers
Which of the following is not a standard view in Microsoft PowerPoint?
Luda [366]
I think the answer would be D. Sorry if i'm wrong but i'm pretty sure it is D.
6 0
2 years ago
Travis is getting ready to present his PowerPoint slides to his class. What is a good tip Travis should use during his presentat
Margaret [11]

Answer:

REad from slide and speak clearly and slowy.

Explanation:

5 0
2 years ago
Other questions:
  • In this scenario, what is the importance of anti-virus software and other similar virus protection programs?
    11·1 answer
  • You have a new phone. What determines what type of messages you can send?
    15·1 answer
  • What is the name of the mvost powerful battery
    6·1 answer
  • Cookies are to improve the access of internet information. Therefore for the sake of you own privacy and security you should not
    8·2 answers
  • when a user has the requirement to stay connected 100% of the time as they move throughout the WLAN coverage area, what are they
    13·1 answer
  • How are online sources used? Check all that apply.
    8·2 answers
  • The reason why our computers can get faster without getting bigger is because of...
    14·1 answer
  • Zoe wants to use an image file that will allow her to preserve all of the original
    10·1 answer
  • Matt uploads a malware sample to a third-party malware scanning site that uses multiple antimalware and antivirus engines to sca
    11·1 answer
  • Debra tracks her business finances in a spreadsheet. She wants to figure out how much she could increase profits if she raises p
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!