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.