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]
2 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]2 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
Is ryan patrick cullen gay
pshichka [43]

who is that? ..........

6 0
2 years ago
Read 2 more answers
Before you can use a navigation control, you must _____. A. configure the web.config B. configure the global.asax C. configure t
natita [175]

Answer:

C

Explanation:

6 0
3 years ago
Read 2 more answers
Who wants to give free points to me?
Bad White [126]

Answer:

I can :) just comment lol

3 0
3 years ago
Read 2 more answers
How many rows appear in a truth table for the compound proposition: \[(p \leftrightarrow q) \oplus (\neg p \leftrightarrow \neg
AURORKA [14]
Let me re-write the proposition:

p↔q⊕(¬p↔¬r)∧¬q.

Generally, the number of rows in a truth table depends on the number of Variables. Here we have 3 Variables: p,q and r. Each of them can have either the value of 1 or 0, which gives us 2*2*2 possibilities, or 2³, that is 8 possibilities and 8 rows:

p=0, q=0, r=0
p=0, q=0, r=1
p=0, q=1, r=0
p=0, q=1, r=1
p=1, q=0, r=0
p=1, q=0, r=1
p=1, q=1, r=0
p=1, q=1, r=1







4 0
2 years ago
Write an if-else statement that displays 'Speed is normal' if the speed variable is within the range of 24 to 56. If the speed v
kari74 [83]

Answer:

import java.util.Scanner;

public class Speed{

int speed;

public Speed(int speed){

this.speed = speed;

}

public void checkSpeed(){

if(speed >= 24 || speed <= 56){

System.out.println("Speed is normal");

}

else

System.out.println("Speed is abnormal");

}

public static void main(String...args){

Scanner input = new Scanner(System.in);

int userSpeed = 0;

System.out.println("Enter a speed: ");

userSpeed = input.nextInt();

Speed obj1 = new Speed(userSpeed)

obj1.checkSpeed();

}

Explanation:

4 0
3 years ago
Other questions:
  • Operating systems are designed to work with specific hardware. Which operating system works with Apple computers?
    8·2 answers
  • Which of the following describes an acceptable print resolution?
    7·1 answer
  • Someone who participates online for social reasons usually has a:
    9·1 answer
  • Netflix uses ________ analytics to suggest which movies we should watch as well as to develop new content that it is confident w
    7·1 answer
  • Select the correct answer
    14·1 answer
  • Sometimes news organizations have biasis because
    5·1 answer
  • Using a conversation voice is part of:
    9·1 answer
  • Which of the following statements is FALSE?
    5·1 answer
  • A palindrome is a string that reads the same from left to right and from right to left. Design an algorithm to find the minimum
    15·1 answer
  • (b) In Scratch, the instruction 'when I receive' enables us to _____ the action of multiple sprites ​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!