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
alukav5142 [94]
3 years ago
15

Write a C program that includes a function of type double called divemaster accepts two double arguments (you must write the div

emaster function). When called, your function will return the first argument divided by the second argument. Make sure your function includes a decision statement so that it can't divide by 0--if the caller attempts to divide by 0 the function should return a value of -1.0.
Computers and Technology
1 answer:
Firlakuza [10]3 years ago
6 0

Answer:

Following is the C program to divide two numbers:

#include<stdio.h>

double divemaster (double first, double second)

{

//Check if second argument is zero or not

if(second!=0)

    return first/second;

else

 return -1.0;

}

int main()

{

printf("%f\n", divemaster(100,20));

printf("%f\n", divemaster(100,0));

}

Output:

5.000000

-1.000000

Explanation:

In the above program, a function divemaster is declared which divedes the first argument with second and return the result.

Within the body of divemaster function if else block is used to verify that the  second argument is not zero, and thus there is no chance of divide by zero error.

In main two printf statements are used to call the divemaster function. One to check normal division process and second to check divide by zero condition.  

You might be interested in
What is the main advantage of using a WYSIWYG("what you see is what you get")editor when constructing a website
Tomtit [17]

Answer:

c

12121212121212121212121212121221212121212121212

7 0
3 years ago
What is the difference between the default constructor and the overloaded constructor?
lukranit [14]

Explanation:

A default constructor is a constructor that present in the class by default with no parameters when we write a new constructor with parameters it is called overloaded constructor.There can be different overloaded constructors in the same class.

The main difference between default constructor and overloaded constructor is that the default constructor does't have any parameters while the overloaded constructors have parameters.

4 0
3 years ago
Would you buy a 2017 SYM WOLF CLASSIC 150 for $2,999?<br><br> Just wondering.
Anika [276]

seeing that its a 2017 it sounds pretty good.... as long as thats really what you want ( you should totally just get a dirt bike lol)

3 0
3 years ago
What may happen if a large number of computer users are trying to access a web site at the same time as you ?
Ber [7]
It Will Say " Too Many People At A Time Trying To Get In " And It Will Say Wait .
6 0
3 years ago
What does GUI stands for and what is it function?​
mars1129 [50]

Answer:

A GUI (graphical user interface) is a system of interactive visual components for computer software. A GUI displays objects that convey information, and represent actions that can be taken by the user. The objects change color, size, or visibility when the user interacts with them.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Write an interactive Python calculator program. The program should allow the user to type a mathematical expression, and then pr
    13·1 answer
  • The following algorithm computes the average height for a list of basketball player heights. Initialize a variable sum to 0. For
    11·2 answers
  • How can you tell that a website is valid and reliable
    7·2 answers
  • Please check my answer! (Java)
    8·1 answer
  • What type of account should you use fro signing in to your windows 8 computer if you want to synchronize your settings on other
    6·1 answer
  • The part of the computer that contains the brain or the Central Park nursing unit is also known as
    10·1 answer
  • A function is executed when it is
    7·1 answer
  • In an array based implementationof a queue a possible solution to dealing with the full condition is to
    14·1 answer
  • Use the Date object and the Array object to determine and diplay information about the current date on your webpage. Your output
    11·1 answer
  • The interprets the data while it is in RAM​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!