how to check if there is a division by zero in c

Posted by user244775 on Stack Overflow See other posts from Stack Overflow or by user244775
Published on 2010-03-21T01:56:01Z Indexed on 2010/03/21 2:01 UTC
Read the original article Hit count: 370

Filed under:
|
#include<stdio.h>
void function(int);

int main()
{
     int x;

     printf("Enter x:");
     scanf("%d", &x);

function(x);

return 0;
}

void function(int x)
{
    float fx;

    fx=10/x;

    if(10 is divided by zero)// I dont know what to put here please help
        printf("division by zero is not allowed");
    else
        printf("f(x) is: %.5f",fx);

}

© Stack Overflow or respective owner

Related posts about checking

Related posts about dividebyzero