Use assert() to check value - C Function

C examples for Function:Utility Function

Description

Use assert() to check value

Demo Code

#include <stdio.h>
#include <math.h>
#include <assert.h>

int main(){/*from  ww  w  .ja v  a2s .  c  om*/
    double x, y, z;
    
    puts("Enter a pair of numbers (0 0 to quit): ");
    while (scanf("%lf%lf", &x, &y) == 2 && (x != 0 || y != 0))
    {
        z = -2;  
        assert(z >= 0);
        printf("answer is %f\n", sqrt(z));
        puts("Next pair of numbers: ");
    }
    
    return 0;
}

Related Tutorials